1

如何将一个或多个事件添加到以这种方式添加的下拉列表中

@Html.DropDownList("List") ?

4

2 回答 2

2

如果你习惯使用 jQuery:,试试这个:

     $("#DropDownListID").change(function () {
        var selectedValue = $(this).val();
        //Do whatever you want to do on selection changes here
     });
于 2012-06-05T09:08:29.150 回答
1
@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

于 2012-06-05T09:07:56.737 回答