首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

|M| 怎么给asp:RadioButtonList添加js onchange="clear()"事件

2012-01-29 
|M| 如何给asp:RadioButtonList添加js onchangeclear()事件asp:RadioButtonListID RadioButtonList1

|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(); ");
}

[解决办法]
都说了.

热点排行