如何将一个或多个事件添加到以这种方式添加的下拉列表中
@Html.DropDownList("List") ?
如果你习惯使用 jQuery:,试试这个:
$("#DropDownListID").change(function () {
var selectedValue = $(this).val();
//Do whatever you want to do on selection changes here
});
@Html.DropDownList("PageItemDD", (SelectList)ViewBag.itemsPerPage, new { onchange = "document.location.href = '/List?ipp=' + this.options[this.selectedIndex].value;" })
部分(DropDownList的new { onchange = "document.location.href = '/List?ipp=' + this.options[this.selectedIndex].value;" }
第三个参数)是 html 属性。在这种情况下,我有一个onchange
加载此页面:/List?ipp= the value of the dropdownlist