我正在使用 AJAX 工具包中的 ModalPopupExtender 控件。该控件扩展了一个包含 CreateUserWizard 控件的面板。但是,CreateUserWizard 控件的验证会导致回发到服务器,从而关闭弹出窗口。我希望弹出窗口保持打开状态,即使在回发之后也是如此。据我所知,我应该使用 UpdatePanel。但是,我似乎无法让它发挥作用。它之所以相当棘手,是因为结构应该是:
ModalPopupExtender
<Panel>
<UpdatePanel>
<ContentTemplate>...</ContentTemplate>
</UpdatePanel>
</Panel>
我无法遵循此结构,因为 ModalPopupExtender
依赖于 CreateUserWizard 控件中包含的按钮。因此,必须将其添加到<asp:CreateUserWizard> </asp:CreateUserWizard>
内。标签。我想要 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 不会关闭?
感谢您的帮助
最佳答案
我设法在不使用 updatepanel 的情况下解决了该问题。相反,我处理了 CreateUserWizard 的“提交”按钮的 onClick 事件。在这里,我获得了 CreateUserWizard 控件中存在的 ModalPopupExtender 实例,并将其称为 Show()
方法。我将 ModalPopup 声明留在 <CustomNavigationTemplate>
中标签,以便 Cancel
按钮仍然可以通过它访问。
关于asp.net - 防止回发时关闭 ModalPopup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2189311/