你如何提交asp.net的MVC一个DropDownList [英] How do you submit a dropdownlist in asp.net mvc

查看:152
本文介绍了你如何提交asp.net的MVC一个DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<% using (Html.BeginForm() { %>

  <%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="[???]" })%>

<% } %>

在上面的例子中,什么样的价值应该在设定的onchange什么?或者,你如何得到正确的形式?

In the above example, what value should you set onchange to? Or, how do you get the correct form?

是否与Ajax.BeginFrom什么区别吗?

Is there any difference with Ajax.BeginFrom?

推荐答案

试试这个:

<%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="this.form.submit();" })%>

在每个表单元素都有一个指向包含此元素的形式的形式属性。

Every form element in the has a "form" property that is pointed to the form that contains this element.

是的,使用的HTML。和阿贾克斯。有区别。阿贾克斯。也就是说,部分页面更新将被使用,整个页面不会重新加载。

Yes, using "Html." and "Ajax." has a difference. Ajax. means that partial page update will be used and the whole page will not be reloaded.

这篇关于你如何提交asp.net的MVC一个DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆