2016-06-15 23 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> 
相關問題