Modal popup + postback

Last post 07-04-2008 11:32 AM by Darkani. 3 replies.

Sort Posts:

  • Modal popup + postback

    07-04-2008, 7:11 AM
    • Loading...
    • Darkani
    • Joined on 06-24-2008, 5:23 AM
    • Posts 31

    First off, im sorry for posting this, I know the question has been up a lot of times but none of the answers I found seem to solve my problem.

    I have a modalpopup on a page and inside the modal's popup box I have a custom usercontrol. This usercontrol is a login form that either validates and sends the user to another page or fails and returns an error.

    Now I found 2 solutions for this, ill post them and the reason I can't use them.

    1. Put an updatepanel inside the modal's popup window.
    This would solve the problem that the modalpopup dissapears after postback (when a wrong username is entered). However I run into a problem, it seems like Response.Redirect isn't working when doing a postback form inside an update panel.
    2. Modalpopupcontrol.Open() (Or something like that) in code-behind
    This would make the whole-page-postback a lot less painful but my problem is I can't access the ModalPopupExtender from inside the Custom User Control.

    I have tried something along the lines of
     

    Page.RegisterStartupScript("reopenPopup",<script type=\"text/javascript\">$find('ctl00_ctrl00_mdlPopup').show()</script>")
     But it didn't do anything.

    So does anyone have a solution? Best would be if someone know of a way to make a response.redirect from inside an UpdatePanel.
  • Re: Modal popup + postback

    07-04-2008, 9:27 AM
    Answer
    • Loading...
    • whatispunk
    • Joined on 03-06-2007, 10:21 PM
    • Winnipeg
    • Posts 721

    Rather than doing a postback from your login control why not asynchronously call a Web Service or a PageMethod. Then depending on the result you can choose to redirect the page via javascript or handle the error.

     http://msdn.microsoft.com/en-ca/library/bb398785.aspx

    Remember: mark posts that helped you as the answer to aid future readers

    Why UpdatePanels Are Dangerous
    Why You Should Not Place Your Whole Site In An UpdatePanel
  • Re: Modal popup + postback

    07-04-2008, 9:54 AM
    Answer

    Dakani,

    With regard to #1, instead of using a Respose.Redirect (which, as you say, doesn't work with partial postbacks), which why not try doing a ScriptManager.RegisterStartupScript() to inject some javascript to redirect your page: window.location = "http://some_address"

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Modal popup + postback

    07-04-2008, 11:32 AM
    • Loading...
    • Darkani
    • Joined on 06-24-2008, 5:23 AM
    • Posts 31
    Thanks for the answers, worked out nicely. I thought I read somewhere that a javascript redirect would open in a new window so didnt even try it.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter