单击中继器中的复选框列表时刷新页面

发布于 2024-12-15 15:05:06 字数 1701 浏览 1 评论 0原文

我对更新面板中的中继器控制这样的问题感到恼火。

<asp:UpdatePanel ID="UpdPnlConstituentRepeater" ChildrenAsTriggers="true"    runat="server">

                            <ContentTemplate>
                                <asp:Repeater ID="repConstituentInformation" runat="server" OnItemDataBound="repConstituentInformation_ItemDataBound">
 <ItemTemplate>
 <asp:DropDownList ID="dropRegistrantDownCostType" runat="server" AppendDataBoundItems="true"
                                                        AutoPostBack="true" OnSelectedIndexChanged="dropRegistrantDownCostType_SelectedIndexChanged"
                                                        EnableViewState="true">
                                                        <asp:ListItem Text="Select Type" Value="0" Selected="True" />
                                                    </asp:DropDownList>

 <asp:CheckBoxList ID="chkBoxListRegistrantBenefits" AutoPostBack="true" runat="server"
                                                        OnSelectedIndexChanged="chkBoxListRegistrantBenefits_SelectedIndexChanged">
                                                    </asp:CheckBoxList>
</itemTemplate>
</ContentTemplate>
</asp:UpdatePanel>

我面临的问题是,每当我从下拉列表中选择任何值时,所有页面都会刷新。在谷歌上花了几个小时后,我找到了一个解决方案,即在中继器的 itemdatabound 事件上,我们只需要在找到下拉列表后添加以下代码,

Dim sm As ScriptManager = ScriptManager.GetCurrent(Page)
            sm.RegisterAsyncPostBackControl(objDropdownlist) 

它非常有效对于下拉列表来说很好,但对于复选框列表同样不起作用,就像使用 scripmanager 实例一样,如果我编写 sm.RegisterAsyncPostBackControl(chkBoxListRegistrantBenefits),它不起作用:(

I am annoyed with a problem I have repeater control in updatepanel like this.

<asp:UpdatePanel ID="UpdPnlConstituentRepeater" ChildrenAsTriggers="true"    runat="server">

                            <ContentTemplate>
                                <asp:Repeater ID="repConstituentInformation" runat="server" OnItemDataBound="repConstituentInformation_ItemDataBound">
 <ItemTemplate>
 <asp:DropDownList ID="dropRegistrantDownCostType" runat="server" AppendDataBoundItems="true"
                                                        AutoPostBack="true" OnSelectedIndexChanged="dropRegistrantDownCostType_SelectedIndexChanged"
                                                        EnableViewState="true">
                                                        <asp:ListItem Text="Select Type" Value="0" Selected="True" />
                                                    </asp:DropDownList>

 <asp:CheckBoxList ID="chkBoxListRegistrantBenefits" AutoPostBack="true" runat="server"
                                                        OnSelectedIndexChanged="chkBoxListRegistrantBenefits_SelectedIndexChanged">
                                                    </asp:CheckBoxList>
</itemTemplate>
</ContentTemplate>
</asp:UpdatePanel>

The problem I face that whenever I select any value from dropdown all the page gets refreshed After spending hours on the google I found a solution i.e, on itemdatabound event of repeater we just need to add the following code after finding the dropdown,

Dim sm As ScriptManager = ScriptManager.GetCurrent(Page)
            sm.RegisterAsyncPostBackControl(objDropdownlist) 

It worked very well for the dropdown but same is not working for checkboxlist like using the scripmanager instance if I write sm.RegisterAsyncPostBackControl(chkBoxListRegistrantBenefits), it is not working :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不美如何 2024-12-22 15:05:07

ClientIDMode="AutoID" 添加到 Repeater 控件。

您不必添加任何触发器,甚至不必调用 RegisterAsyncPostBackControlChildrenAsTriggers 应该处理这个问题。

Add ClientIDMode="AutoID" to the Repeater control.

You should not have to add any triggers and you should not even have to call RegisterAsyncPostBackControl. The ChildrenAsTriggers should take care of that.

绳情 2024-12-22 15:05:07

在 Repeater ItemDataBound 事件上

使用 screiptmanager 方法 RegisterAsyncPostBackControl

this.ScriptManager1.RegisterAsyncPostBackControl(
e.Item.FindControl(" 将您的复选框 ID 放在这里"));

on Repeater ItemDataBound event

use screiptmanager method RegisterAsyncPostBackControl

this.ScriptManager1.RegisterAsyncPostBackControl(
e.Item.FindControl(" put here your checkbox ID "));

很酷又爱笑 2024-12-22 15:05:07

开始之前添加以下内容:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="objDropdownlist" EventName="OnSelectedIndexChanged" />
</Triggers>

Add this Before start of <ContentTemplate>:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="objDropdownlist" EventName="OnSelectedIndexChanged" />
</Triggers>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文