2016-06-15 39 views
0

我有一个更新面板在我的aspx页面有一个radiobuttonlist和一个按钮。当点击按钮而没有从列表中选择任何单选按钮时,单击事件可以正常工作,但是当我选中单选按钮之一,然后单击该按钮时,没有回发或按钮单击事件不会触发。下面是相同的截图:检查更新面板内的任何单选按钮后按钮点击事件不会触发

enter image description here

任何建议或答案可以理解的!

+0

请告诉我们有关的标记。 – ConnorsFan

回答

0

请尝试以下的例子:

后面的代码:

public partial class AjaxUpdatePanelExample : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if(!Page.IsPostBack) 
     { 
      RadioButtonList1.DataSource = new List<string> { "option 1", "option 2", "option 3" }; 
      RadioButtonList1.DataBind(); 
     } 
    } 

    protected void btnSubmit_Click(object sender, EventArgs e) 
    { 
     lblSelectedOption.Text = String.Format("Selected option - {0}",RadioButtonList1.SelectedValue); 
    } 
} 

.ASPX:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
     <asp:RadioButtonList ID="RadioButtonList1" runat="server"> 
     </asp:RadioButtonList> 
     <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /> 
     <asp:Label ID="lblSelectedOption" runat="server"></asp:Label> 
    </ContentTemplate> 
</asp:UpdatePanel> 
相关问题