如何在MVC 3的第一个下拉列表中单击以填充第二个下拉列表 [英] How to fill second drop down on the click of first drop down in mvc 3
本文介绍了如何在MVC 3的第一个下拉列表中单击以填充第二个下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1.国家
2.状态
3.城市
所有表都具有主键,外键.
现在,如何在mvc3中的国家/地区"下拉列表中填写州下拉列表,并在国家/地区"下拉列表中单击相应的城市下拉列表.
谢谢,
解决方案
DropDownList控件的OnSelectedIndexChanged事件,您可以在列表中填充适当的数据.
< aspropdownlist cssclass =" id =" =" tabindex =" 自动回发 =" önselectedindexchanged =" > < /aspropdownlist var url = ' @ Url.Action("ActionName","ControllerName")';
(" #Country").change( 解决方案
OnSelectedIndexChanged event of DropDownList control, you can fill the appropriate data in the list.
<aspropdownlist cssclass="TxtBox" id="Project" runat="server" tabindex="13" autopostback="true" önselectedindexchanged="Country_SelectedIndexChanged"></aspropdownlist>
Country_SelectedIndexChanged event will fill the adjacent DropDownList controls State and City.
You could achieve this using jquery and a call from your view to a JSON action on your controller...
Some jquery in your View..
var url = '@Url.Action("ActionName", "ControllerName")';
("#Country").change(function () {
这篇关于如何在MVC 3的第一个下拉列表中单击以填充第二个下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文