Asp.net mvc 如何将事件添加到以这种方式添加的下拉列表@Html.DropDownList(“列表”)?
如何将一个或多个事件添加到以这种方式添加的dropdownlist @Html.DropDownList(“列表”)Asp.net mvc 如何将事件添加到以这种方式添加的下拉列表@Html.DropDownList(“列表”)?,asp.net-mvc,Asp.net Mvc,如何将一个或多个事件添加到以这种方式添加的dropdownlist @Html.DropDownList(“列表”) 新的{onchange=“document.location.href=”/List?ipp=”+this.options[this.selectedIndex].value;“}部分(DropDownList的第三个参数)是html属性。在本例中,我有一个加载此页面的onchange:/List?ipp=dropdownlist的值如果您对使用jQuery感到满意:,请尝试以下
新的{onchange=“document.location.href=”/List?ipp=”+this.options[this.selectedIndex].value;“}部分(DropDownList的第三个参数)是html属性。在本例中,我有一个加载此页面的
onchange
:/List?ipp=dropdownlist的值
如果您对使用jQuery感到满意:,请尝试以下操作:
$("#DropDownListID").change(function () {
var selectedValue = $(this).val();
//Do whatever you want to do on selection changes here
});
对htmlAttributes使用另一个重载或使用jquery。。。如何在HtmlAttributes中使用另一个重载只是为了确保:您使用的是mvc或webforms?在这个项目中,我使用的是MVCI,是否可以在这里@Html.DropDownList(“列表”)中插入事件?如果是,那么是的,但是您应该尽可能使用不引人注目的JavaScript。请参阅此以了解更多详细信息
$("#DropDownListID").change(function () {
var selectedValue = $(this).val();
//Do whatever you want to do on selection changes here
});