[英]RadioButtonList OnSelectedIndexChanged Only firing ONCE
I have a radiobuttonlist that is hardcoded into my asp.net page like so: 我有一个单选按钮列表,它被硬编码到我的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>
The code behind is as follows: 后面的代码如下:
protected void rblOrientation_onSelectedIndexChanged(object sender, EventArgs e)
{
ddlPaperSize_onSelectedIndexChanged(sender, e);
}
Basically what happens is it calls on another function which updates a bunch of values that are within an update panel. 基本上发生的事情是它调用另一个函数,该函数更新更新面板中的一堆值。 This is also hardcoded in and looks like this:
这也是硬编码的,看起来像这样:
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Label ID="lblPaperWidth" runat="server" />
<span id="txtUOMWidth" runat="server" /> ×
<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>
Everything works fine the first time I change the value of the radiobuttonlist, however, if I try a second time it does not work. 第一次更改单选按钮列表的值时,一切正常,但是,如果第二次尝试不起作用,则一切正常。 Does anyone know why this might be?
有谁知道为什么会这样吗? Any advice would be great, thanks!
任何建议都很好,谢谢!
note: From the testing I have done, this is the only control where the OnSelectedIndexChanged is not acting how I expected it to. 注意:从我已经完成的测试中,这是唯一的控件,其中OnSelectedIndexChanged并未按我期望的那样起作用。 The event for the rest of the controls fires correctly
其余控件的事件正确触发
Try this code, which works fine for me. 试试这个代码,对我来说很好。
<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.