Prevent closing of ModalPopup on postback

keyboardP picture keyboardP · Feb 3, 2010 · Viewed 15k times · Source

I'm using the ModalPopupExtender control from the AJAX toolkit. This control extends a panel which contains a CreateUserWizard control. However, the validation of the CreateUserWizard control causes a postback to the server, which closes the popup. I'd like the popup to remain open, even after the postback. From what I can gather, I should be using an UpdatePanel. However, I can't seem to get it working. The reason it's being quite tricky is because the structure should be :

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

I can't follow this structure because the ModalPopupExtender relies on a button which is contained within the CreateUserWizard control. Therefore, it has to be added within the <asp:CreateUserWizard> </asp:CreateUserWizard> tags. I would like the submit button, built into the CreateUserWizard control, to force an update of the panel. Any suggestions on how the structure should be? My code is highly customised, so it's quite long. However, the key structure is similar to this:

<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>

Whereabouts would the UpdatePanel be placed? Or is there a more efficient way of ensuring the ModalPopup doesn't close?

Thanks for any help

Answer

keyboardP picture keyboardP · Feb 3, 2010

I managed to solve the problem without using the updatepanel. Instead, I handled the CreateUserWizard's 'Submit' button's onClick event. Here, I got the instance of the ModalPopupExtender existing within the CreateUserWizard control and called its Show() method. I left the ModalPopup declaration within the <CustomNavigationTemplate> tags so that the Cancel button can still be accessed by it.