簡體   English   中英

RadioButtonList OnSelectedIndexChanged僅觸發一次

[英]RadioButtonList OnSelectedIndexChanged Only firing ONCE

我有一個單選按鈕列表,它被硬編碼到我的asp.net頁面中,如下所示:

<asp:RadioButtonList runat="server" ID="rblOrientation" RepeatDirection="Horizontal"
    OnSelectedIndexChanged="rblOrientation_onSelectedIndexChanged" AutoPostBack="true">
    <asp:ListItem Text="Portrait" Value="P" Selected="True"></asp:ListItem>
    <asp:ListItem Text="Landscape" Value="L"></asp:ListItem>
</asp:RadioButtonList>

后面的代碼如下:

protected void rblOrientation_onSelectedIndexChanged(object sender, EventArgs e)
{
    ddlPaperSize_onSelectedIndexChanged(sender, e);
}

基本上發生的事情是它調用另一個函數,該函數更新更新面板中的一堆值。 這也是硬編碼的,看起來像這樣:

<asp:UpdatePanel runat="server">
    <ContentTemplate>
        <asp:Label ID="lblPaperWidth" runat="server" />
        <span id="txtUOMWidth" runat="server" />&nbsp;×
        <asp:Label ID="lblPaperHeight" runat="server" />
        <span id="txtUOMHeight" runat="server" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="rblOrientation" />
        <asp:AsyncPostBackTrigger ControlID="ddlPaperSize" />
        <asp:AsyncPostBackTrigger ControlID="ddlScale" />
    </Triggers>
</asp:UpdatePanel>

第一次更改單選按鈕列表的值時,一切正常,但是,如果第二次嘗試不起作用,則一切正常。 有誰知道為什么會這樣嗎? 任何建議都很好,謝謝!

注意:從我已經完成的測試中,這是唯一的控件,其中OnSelectedIndexChanged並未按我期望的那樣起作用。 其余控件的事件正確觸發

試試這個代碼,對我來說很好。

<asp:ScriptManager ID="smMain" runat="server" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" >      
      <ContentTemplate>
        <asp:RadioButtonList runat="server" ID="rblOrientation" RepeatDirection="Horizontal"
             OnSelectedIndexChanged="rblOrientation_onSelectedIndexChanged" AutoPostBack="true">
         <asp:ListItem Text="Portrait" Value="P" Selected="True"></asp:ListItem>
         <asp:ListItem Text="Landscape" Value="L"></asp:ListItem>
        </asp:RadioButtonList>

      </ContentTemplate>
    </asp:UpdatePanel>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM