【问题标题】:Prevent closing of ModalPopup on postback防止在回发时关闭 ModalPopup
【发布时间】:2010-02-03 02:45:16
【问题描述】:

我正在使用 AJAX 工具包中的 ModalPopupExtender 控件。此控件扩展了包含 CreateUserWizard 控件的面板。但是,CreateUserWizard 控件的验证会导致回发到服务器,从而关闭弹出窗口。我希望弹出窗口保持打开状态,即使在回发之后也是如此。据我所知,我应该使用 UpdatePanel。但是,我似乎无法让它工作。它非常棘手的原因是结构应该是:

ModalPopupExtender
<Panel>
<UpdatePanel>
<ContentTemplate>...</ContentTemplate>
</UpdatePanel>
</Panel>

我无法遵循这种结构,因为ModalPopupExtender 依赖于包含在 CreateUserWizard 控件中的按钮。因此,必须将其添加到&lt;asp:CreateUserWizard&gt; &lt;/asp:CreateUserWizard&gt; 标记中。我希望 CreateUserWizard 控件中内置的提交按钮强制更新面板。关于结构应该如何的任何建议?我的代码是高度定制的,所以它很长。但是,关键结构是这样的:

<asp:Panel>
  <asp:CreateUserWizard>
    <WizardSteps>
       <asp:CreateUserWizardStep>
          <ContentTemplate>

          //Form Controls here
          </ContentTemplate>
          <CustomNavigationTemplate>
               //The SUBMIT button that should force update
               //CANCEL button
             <asp:ModalPopupExtender /> //References the CANCEL button therefore has to be here
          </CustomNavigationTemplate>

       </asp:CreateUserWizardStep>
    </WizardSteps>
</asp:CreateUserWizard>

</asp:Panel>

UpdatePanel 应该放在哪里?或者有没有更有效的方法来确保 ModalPopup 不会关闭?

感谢您的帮助

【问题讨论】:

    标签: asp.net ajax postback modalpopupextender createuserwizard


    【解决方案1】:

    我设法在不使用更新面板的情况下解决了这个问题。相反,我处理了 CreateUserWizard 的“提交”按钮的 onClick 事件。在这里,我得到了存在于 CreateUserWizard 控件中的 ModalPopupExtender 实例,并调用了它的Show() 方法。我将 ModalPopup 声明保留在 &lt;CustomNavigationTemplate&gt; 标记中,以便它仍然可以访问 Cancel 按钮。

    【讨论】:

      【解决方案2】:

      使用客户端验证或使用更新面板包装您的面板并调用模态扩展器的 Show() 方法以从代码隐藏中显示模态。

      【讨论】:

      • 我尝试将 UpdatePanel 放在整个面板周围,但我只收到 An extender can't be in a different UpdatePanel than the control it extends. 错误。
      • 你不应该把你的扩展器放在不同的更新面板中。如果您使用的是嵌套的 UpdatePanel,则需要将扩展​​器从内部 UpdatePanel 中移出,或移除内部 UpdatePanel。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多