【问题标题】:AJAX ModalPopup update panel contents based on change in panel controlsAJAX ModalPopup 根据面板控件的变化更新面板内容
【发布时间】:2010-08-30 15:33:12
【问题描述】:

我有一个 AJAX 模态弹出面板,其中包含一个 RadioButtonList、2 个标签和 2 个下拉菜单。我想在选择单选按钮时更新标签和下拉菜单。我在此帖子上的尝试导致 ajax 弹出窗口消失。

图片点击时调用aspx:

<asp:Panel ID="pnlModalContainer" runat="server">
    <asp:RadioButtonList ID="rblTest" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblTest_SelectedIndexChanged">
      <asp:ListItem Text="Test 1" Value="1" Selected="True" />
      <asp:ListItem Text="Test 2" Value="2" />
    </asp:RadioButtonList>
    <br />
    <asp:Label ID="lblFoo" Text="Foo" />
    <asp:Label ID="lblBar" Text="Bar" />
    <asp:DropDownList ID="ddlDogs" runat="server" DataSourceID="odsDogs" DataTextField="Dog" DataValueField="DogID" />
    <asp:DropDownList ID="ddlCats" runat="server" DataSourceID="odsCats" DataTextField="Cat" DataValueField="CatID" />
</asp:Panel>

代码背后(vb.net):

Protected Sub rblTest_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rblTest.SelectedIndexChanged
   ' ???
   ' Make it change lblFoo.Text and lblBar.Text as well as the DataSource for the DDLs
End Sub

【问题讨论】:

    标签: asp.net ajax ajaxcontroltoolkit


    【解决方案1】:

    您需要在pnlModalContainer 中添加一个UpdatePanel。

    【讨论】:

    • 即使 pnlModalContainer 已经在 UpdatePanel 中?它们应该嵌套吗?
    • 是的。基本上,您的 PostBack 告诉页面替换 UpdatePanel 中的所有内容(在本例中为模态面板的标记)。发生这种情况时,页面上不再存在模态,因此无法继续显示。嵌套 UpdatePanels 很好。确保仅将需要更新的项目包围在它们自己的面板中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多