【问题标题】:Update Panel Only Updates Once Radio Button List Async Postback更新面板仅更新一次单选按钮列表异步回发
【发布时间】:2012-05-18 20:30:09
【问题描述】:

我正在尝试使用单选按钮列表来更改更新面板中的一些标签文本,但无论出于何种原因,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>

【问题讨论】:

  • 刚刚意识到我的帖子中缺少一些代码...用作触发器的单选按钮列表位于一个面板中,该面板不在此面板或任何更新面板中,而只是一个常规的 asp:panel ,所以这就是为什么你没有在我发布的代码中看到它的定义......
  • 所以即使 RadioButtonList 没有 AutoPostBack="True",它仍然会执行回发...但只有一次?
  • 跳过 AsyncPostBackTrigger,RadioButtonList 应该回发,条件模式是正确的选择。

标签: asp.net vb.net updatepanel selectedindexchanged


【解决方案1】:

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

 UpdatePanel1.Update()

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

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-08
        • 1970-01-01
        • 2011-08-24
        • 1970-01-01
        相关资源
        最近更新 更多