开发者

autopostback for dropdownlist in mvc.net

how to set autopostback for dropdownlist i开发者_如何学编程n mvc.net?


You don't - there's no concept of 'autopostback', in the same way that there is no postback concept in the MVC framework.

If you want to submit the form, you can do that via javascript, if you want to update something else via a call to the server, you can set up an AJAX call, probably using jQuery to do so.

There's a bit of an example here.


no jquery required. wrap each hidden id and dropdown in a form with the action to updateproduct. then its just:

@Html.DropDownList("id", (SelectList)ViewBag.Values, new { onchange = "this.form.submit();" })


autopostback supports only in asp.net not in mvc.net, so you just need to write @Html.DropDownList("id", (SelectList)ViewBag.Values, new { onchange = "this.form.submit();" }) or jquery function in the cshtml file script section.


One thumb rule for MVC, Any method of controller, on be called by JS or Jquery thru Ajax calling routing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜