Hello,
I'm trying to pass a List object from view to controller.
The program works by pressing the link "Add new line", this adds a new row to my web page, with a input box and i would like for that input box content, on submission, to be passed to my controller so that a can treat the data...
The code would be something like this

@model MyModel.Models.Line

@{
    ViewBag.Title = "Create";
}
@{
    Layout = "";
}

<h2> New Line</h2>

@using (Html.BeginForm())
{   
    @Html.ValidationSummary(true)
    @{var lines = new List<MyModel.Models.lines>();}
    <table class="createTable">
    </table>
    <a href="#" class="addNew">Add new line</a>
    <script type="text/javascript">
        $(function () {
                    jQuery(function () {
                        @{var line = new MyModel.Models.Line();}
                        jQuery('a.addNew').click(function (event) {
                            event.preventDefault();
                            jQuery('table.tableCreate').append('<tr><td>@Html.EditorFor(m=>line.Description)</td></tr>');

                        });
                    });
        });
    </script>
    <input type="submit" value="OK">
}

I would like some help, please.

Recommended Answers

All 3 Replies

Thanks pritaeas.
From what i gathered in jQuery.ajax({data:{'listID':ids}}) data will be sent in the query string, would it be possible to not adding to the query and pass data another way?
Thanks in advance :)

Use type: 'POST' in your ajax call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.