2

我正在尝试使用单选按钮列表来更改更新面板中的一些标签文本,但无论出于何种原因,SelectedIndexChanged 事件似乎只会第一次触发,然后再也不会触发。我用谷歌搜索和搜索,但我发现尝试的所有东西都没有解决这个问题。

Autopostback 设置为 true,我尝试了标准的 .net ScriptManager 和 ToolkitScriptManager,两者的行为相同,我尝试在 Trigger 中指定 Event 并未指定它(这会退回到该控件类型的默认值) ...我还尝试将 rbl 绑定到 if not me.ispostback then... 页面加载事件的结构中。

我在事件中使用的 VB 只是一个简单的 如果选择了这个索引, label.text="whatever" else "yadda" ... 没什么特别的。如果更新面板不在播放中,这一切都很好,除了我希望从完整的回发中摆脱屏幕闪烁。我把我的asp.net的肉和土豆贴在下面……救命!

类型1 类型2
    <asp:Panel ID="DesignInfoHeaderPanel" runat="server" CssClass="headerpanel">

        <asp:Label ID="lblDesignInfo" runat="server" font-bold="true"
            style="z-index: 1; left: 5px; top: 5px; position: absolute" Text="Design Information"></asp:Label>

    </asp:Panel>

    <div class="cpdiv">
    <asp:Panel ID="DesignInfoPanel" runat="server" CssClass="collapsepanel">

        <asp:UpdatePanel runat="server" ID="DIUpdatePanel" UpdateMode="Conditional">

            <ContentTemplate>

                <asp:Label ID="Label1" runat="server" font-bold="true"
                    style="z-index: 1; left: 5px; top: 7px; width: 95px; position: absolute; text-align: right"
                    Text="Account Name"></asp:Label>

                <asp:TextBox ID="TextBox1" runat="server" Font-Names="Verdana" Font-Size="8pt"
                    style="z-index: 1; left: 110px; top: 4px; width: 144px; position: absolute"></asp:TextBox>

                <asp:Label ID="Label2" runat="server" font-bold="true"
                    style="z-index: 1; left: 270px; top: 7px; width: 140px; position: absolute"
                    Text="Est. Volume (# units)"></asp:Label>

                <asp:TextBox ID="TextBox2" runat="server" Font-Names="Verdana" Font-Size="8pt"
                    style="z-index: 1; left: 415px; top: 4px; width: 60px; position: absolute"></asp:TextBox>

                <asp:Label ID="Label3" runat="server" font-bold="true"
                    style="z-index: 1; left: 7px; top: 35px; width: 95px; position: absolute; text-align: right"
                    Text="Sales Manager"></asp:Label>

                <asp:DropDownList ID="DropDownList1" runat="server" Font-Names="Verdana" Font-Size="8pt"
                    style="z-index: 1; left: 110px; top: 32px; width: 150px; position: absolute">
                </asp:DropDownList>

                <asp:Label ID="Label4" runat="server" font-bold="true"
                    style="z-index: 1; left: 485px; top: 7px; width: 140px; position: absolute"
                    Text="Personalization Type"></asp:Label>

                <asp:DropDownList ID="DropDownList2" runat="server" Font-Names="Verdana" Font-Size="8pt"
                    style="z-index: 1; left: 630px; top: 4px; width: 150px; position: absolute">
                </asp:DropDownList>

                <asp:CheckBox ID="CheckBox1" runat="server" font-bold="true"
                    style="z-index: 1; left: 298px; top: 32px; position: absolute" Text="Rental"
                    TextAlign="Left" />

                <asp:CheckBox ID="CheckBox2" runat="server" font-bold="true"
                    style="z-index: 1; left: 397px; top: 32px; position: absolute" Text="Dir Sales"
                    TextAlign="Left" />

                <asp:RadioButtonList ID="RadioButtonList1" runat="server" BorderColor="#640000"
                    BorderStyle="Solid" BorderWidth="2px" Font-Bold="true"
                    RepeatDirection="Horizontal"
                    style="z-index: 1; left: 545px; top: 28px; position: absolute"
                    TextAlign="Left">
                    <asp:ListItem Value="0">Type1</asp:ListItem>
                    <asp:ListItem Value="1">Type2</asp:ListItem>
                </asp:RadioButtonList>

            </ContentTemplate>

            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="rblEmblemType" />
            </Triggers>

            </asp:UpdatePanel>
4

3 回答 3

0

尝试添加ClientIDMode="AutoID"到您的 RadioButtonList。

于 2014-12-18T18:20:02.667 回答
0

可能是因为 UpdatePanel 正在更新。由于您尚未发布有关您的代码脚本的任何信息,因此我假设您尚未在事件方法中使用以下代码。

 UpdatePanel1.Update()

这(下一个)发生的可能性较小。

如果您使用 AutoPostBack,则不需要使用 asyncPostBackTrigger ..!当图像按钮/图像/网格..etc 事件发生或发生此错误时,您需要使用触发器

无法解析从服务器收到的消息。

于 2013-11-20T09:59:25.327 回答
0

我的代码和你的非常相似。在我的情况下,当我设置 PostBackTrigger 时会触发 SelectedIndexChanged 事件。实际上,事件仅触发一次意味着单击事件附加到其他单选按钮(未选中)。所以,我只是解决了删除“Selected=true”

于 2020-04-14T09:28:40.260 回答