我已经为我的单选按钮和下拉列表使用了helpers (RadioButtonLists、DropDownListFor和EnumDropDownListFor)。示例:
@Html.RadioButtonList(m => m.ItemType, new SelectList(Model.ItemTypes, "Name", "Name")和
@Html.DropDownListFor(n => n.ApartmentFloor, new SelectList(Model.ApartmentFloors, "Id", "Floor"), new { @id = "floorsSelect", @class = "exists" })对于DropDownListFor来说,似乎有一些方法可以设置列表的属性,例如。id、类、样式等等。但是对于RadioButtonList,它实际上是一个自定义类(my version和original),我似乎找不到一种方法来添加这些类型的属性。
我想到的是"onchange“。如何向这些类型的帮助器添加onchange函数?
发布于 2012-11-16 21:34:21
查看您的"RadioButtonList“所呈现的html &获取控件的id,然后您可以使用下面的jQuery代码轻松地关联"onchange”事件。
$("#RadioButtonListID input").change(function(){
//Write Your Code Here
});https://stackoverflow.com/questions/13417099
复制相似问题