.net MVC Razor RadioButtonList onchange处理程序

.net MVC Razor RadioButtonList onchange处理程序,.net,asp.net-mvc-3,razor,radiobuttonlist,.net,Asp.net Mvc 3,Razor,Radiobuttonlist,我已经为我的单选按钮和下拉列表使用了HTML帮助程序(RadioButtonList、DropDownListFor和EnumDropDownListFor)。例如: @Html.RadioButtonList(m => m.ItemType, new SelectList(Model.ItemTypes, "Name", "Name") 及 对于DropDownListFor,似乎有一些方法可以设置列表的HTML属性,例如id、类、样式等。 但是对于RadioButtonList,它实

我已经为我的单选按钮和下拉列表使用了HTML帮助程序(RadioButtonList、DropDownListFor和EnumDropDownListFor)。例如:

@Html.RadioButtonList(m => m.ItemType, new SelectList(Model.ItemTypes, "Name", "Name")

对于DropDownListFor,似乎有一些方法可以设置列表的HTML属性,例如id、类、样式等。 但是对于RadioButtonList,它实际上是一个自定义类(和),我似乎找不到添加这些类型属性的方法


我想到的是“onchange”。如何向这些类型的助手添加onchange函数?

请查看“RadioButtonList”的呈现html并获取控件的id,然后可以使用以下jQuery代码轻松关联“onchange”事件

$("#RadioButtonListID input").change(function(){
//Write Your Code Here
});

您应该在Javascript中添加处理程序。
$("#RadioButtonListID input").change(function(){
//Write Your Code Here
});