c# - How do I submit only a part of a (large) form in ASP.NET MVC? -
i have model list of objects rendering out page within form. user selects objects checkbox, hits submit, model posted , perform processing on selected items.
@using (html.beginform("method", "controller")) { <table id="mytable"> <tr> <th>some properties</td> <th>selected</td> </tr> @foreach (var item in model) <tr> @html.hiddenfor(m => item.id) <td>@item.id</td> <td>@html.checkboxfor(m => item.selected)</td> </tr> </table> <input id="btngo" type="submit" name="submitbutton" value="go"/> }
(that it. don't think above works - had seperate out 'foreach' part in partial view - i'm sure idea).
usually there aren't many rows, there can lot.
when high (2000 plus), if user ticks 1 box, can take 10 minutes post entire model, when 99.9% of not needed.
how go submitting relevent (checked) items model?
the way work submitting checked items javascript forcefulness url.
$(document).ready(function () { $('#btngo').click(function () { var idarray = new array(); $("#mytable input:checkbox:checked").each(function () { idarray.push(this.id); }); window.location = "/my.web.page/controller/method?selectedids=" + idarray; }); });
but don't because i'm having hardcode url, , user can nail 'refresh' on browser reprocess everything.
well, using html can't partial postbacks. if need able post data, should utilize ajax.
btw, 10min processing on 2000 items? doing data?!
c# asp.net-mvc asp.net-mvc-3
No comments:
Post a Comment