2011-11-24 142 views
0

我目前調用從同一按鈕點擊這樣的客戶端功能和服務器端功能...能從Asp:RadioButtonList調用客戶端和服務器端代碼嗎?

<asp:Button id="myButton" 
      runat="server" 
      cssclass="myButtonClass" 
      text="Do Stuff" 
      onclick="Do_Foo" 
      OnClientClick="Do_Bar();"/> 

我想知道如果事情analagous是可能的一個單選按鈕列表...

<asp:RadioButtonList id="myRadioButtonList" 
        runat="server" 
        AutoPostBack="True" 
        onselectedindexchanged="Do_Fum" 
        ...er...something here?> 
    <asp:ListItem ...or here perhaps?... Value="0">First Button</asp:ListItem> 
    . 
    . 

回答

1

您可以使用下面的方法:在p的下方粘貼代碼年齡的Page_PreRender事件處理程序

foreach (ListItem item in myRadioButtonList.Items) 
{ 
    item.Attributes["onclick"] = "if(!confirm('Are you sure?'))return false"; 
} 
+0

謝謝。那是第一次。 –

0

您可以在javascript掛鉤的改變事件單選按鈕像

$('#myRadioButtonList').change(function() { 
    alert('Handle Your Change'); 
}); 
+0

謝謝。我應該把那個小片段放在哪裏? –

+0

其jquery,只是把它放在'