日期:2014-05-19  浏览次数:20457 次

|M| 如何给asp:RadioButtonList添加js onchange="clear()"事件
<asp:RadioButtonList   ID= "RadioButtonList1 "   runat= "server "   RepeatDirection= "Horizontal ">
    <asp:ListItem   Value= "-1 "   onchange= "clear() "> 学生 </asp:ListItem>
    <asp:ListItem   Value= "0 "> 教师 </asp:ListItem>
</asp:RadioButtonList>                
而他生成的html则是
<table   id= "RadioButtonList1 "   border= "0 ">
    <tr>
        <td> <span   onchange= "clear() "> <input   id= "RadioButtonList1_0 "   type= "radio "   name= "RadioButtonList1 "   value= "-1 "   /> <label   for= "RadioButtonList1_0 "> 学生 </label> </span> </td> <td> <input   id= "RadioButtonList1_1 "   type= "radio "   name= "RadioButtonList1 "   value= "0 "   /> <label   for= "RadioButtonList1_1 "> 教师 </label> </td>
</tr>
</table>                                  

怎样来正确添加js   onchange= "clear() "事件
谢谢

------解决方案--------------------
用onclick就可.
------解决方案--------------------
后台Page_OnLoad()方法中添加
RadioButtonList1.Attributes.Add( "onchange ", "clear() ");
------解决方案--------------------
for (int ix = 0; ix < RadioButtonList1.Items.Count; ix++ )
{
RadioButtonList1.Items[ix].Attributes.Add( "onchange ", "clear(); ");
}

------解决方案--------------------
都说了.