Popup window and Response.Redirect

Last post 11-12-2009 2:38 PM by avmood. 12 replies.

Sort Posts:

  • Popup window and Response.Redirect

    11-12-2009, 11:18 AM
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    Hi, I have an application where when I hit a button NEXT, it will pupup a window and at the same time it goes to a different page.

    I have the following code and the problem is it only goes to Step2.aspx, and no window popup. However, if I delete the code Response.Redirect("Step2.aspx"), then the popup windows work. How can I have 2 at the same time so that both the popup window pop up and it goes to the next page?


    string url="http://www.test.com/abc.aspx";

    Response.Write("<script language=\"javascript\">window.open('" + url+ "','SportZip',toolbar='0,scrollbars=-1,resizable=-1');void(0);</script>");

    Response.Redirect("Step2.aspx");

  • Re: Popup window and Response.Redirect

    11-12-2009, 11:24 AM
    • Contributor
      5,246 point Contributor
    • irokhes
    • Member since 10-29-2009, 5:46 AM
    • Posts 794

    Hi,

    you could use an Ajax modalpopup control (http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx) and then when user close window redirect to another page. If you want execute both instruction at same time you have to use multi thread progamming model.

     

    good luck

    Please mark this post as answered if it helped you!

    mY BlOg
  • Re: Popup window and Response.Redirect

    11-12-2009, 11:34 AM

    Response.Redirect will move you to the next page before the page is rendered.  Also, you shouldn't be usig Response.Write for the JS code.  Instead use something like this:

    ClientScript.RegisterStartupScript(GetType(), "scriptKey", "window.open('" + url + "','SportZip',toolbar='0,scrollbars=-1,resizable=-1');window.location='Step2.aspx';)", true);
    


     

    I might have some syntax errors, but you get the idea...

  • Re: Popup window and Response.Redirect

    11-12-2009, 11:39 AM
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    I did it in classic asp without using multiple thread and it works fine. is there a way to do that without using multiple thread?

  • Re: Popup window and Response.Redirect

    11-12-2009, 11:40 AM
    • Member
      122 point Member
    • ahmadZaher1
    • Member since 04-07-2009, 4:17 PM
    • Posts 32


    hi, try this

    string url="http://www.test.com/abc.aspx";

    Response.Write("<script language=\"javascript\">

    function move() {
    window.location = '/step2.aspx';
    }

    window.open('" + url+ "','SportZip',toolbar='0,scrollbars=-1,resizable=-1');void(0);

    setTimeout('move()',200);


    </script>");



    pls tell me yor results ;

    thank you



    ____________________________________________
    if it helps you pls mark as an answer
    thanks
    Ahmad Zaher
    MCTS,MCPD
  • Re: Popup window and Response.Redirect

    11-12-2009, 11:47 AM
    • Participant
      1,639 point Participant
    • vishwaraj1
    • Member since 11-07-2008, 7:44 PM
    • India
    • Posts 423

    do like this....
    
    redirect to another page and  write this on the Pageload or page2
    
    protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", 
    
    "window.alert('Show your message here.','');", true);
        }



    Regards:

    Vishwaraj Malik

    VB to C# Converter


    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: Popup window and Response.Redirect

    11-12-2009, 11:56 AM
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    Hi, I cannot redirect to another page because I have to do it on the current page. The popup page depends on other properties of the current page and it is conditional depends on what user selected.

  • Re: Popup window and Response.Redirect

    11-12-2009, 12:01 PM
    • Participant
      1,639 point Participant
    • vishwaraj1
    • Member since 11-07-2008, 7:44 PM
    • India
    • Posts 423

    so you can check the condition on the page load of other page  
    and send the condition in querystrind 
    
    when you do it on pageload of other page then the message show 
    up before loading that page.
    
    so you can try that..



    Regards:

    Vishwaraj Malik

    VB to C# Converter


    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: Popup window and Response.Redirect

    11-12-2009, 1:16 PM
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    Yah, I cannot do that because there are other business rules and middle pages before I get to the final page. The step2.aspx is just a place holder and on top of that there is a frame which directs to another page which I cannot modify. So I cannot easily move these logic to the next page.

  • Re: Popup window and Response.Redirect

    11-12-2009, 2:05 PM
    • Member
      122 point Member
    • ahmadZaher1
    • Member since 04-07-2009, 4:17 PM
    • Posts 32

    did you tried my code , what is the problem with it , just get the absolute url for the step2 page


    ____________________________________________
    if it helps you pls mark as an answer
    thanks
    Ahmad Zaher
    MCTS,MCPD
  • Re: Popup window and Response.Redirect

    11-12-2009, 2:11 PM
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    I got it. I need to use Response.Write for javascript popup and Server.Transfer to go to the next page. It will show 2 windows. If I use the ScriptManager.RegisterStartupScript, it doesn't work.

  • Re: Popup window and Response.Redirect

    11-12-2009, 2:27 PM
    • Member
      122 point Member
    • ahmadZaher1
    • Member since 04-07-2009, 4:17 PM
    • Posts 32

    please try this and tell me :

    string url="http://www.test.com/abc.aspx";

    Response.Write(@"<script language="javascript">

    function move() {
    window.location = '"+
    Request.Url.AbsoluteUri.Replace(Request.Url.LocalPath, "/step2.aspx")+@"
    }

    window.open('" + url+ @"','SportZip',toolbar='0,scrollbars=-1,resizable=-1');void(0);

    setTimeout('move()',200);


    </script>");

    ____________________________________________
    if it helps you pls mark as an answer
    thanks
    Ahmad Zaher
    MCTS,MCPD
  • Re: Popup window and Response.Redirect

    11-12-2009, 2:38 PM
    Answer
    • Member
      459 point Member
    • avmood
    • Member since 02-17-2008, 12:20 PM
    • Posts 840

    Thanks, I already got it working. Here's my code

    string url="http://www.test.com/abc.aspx";

    Response.Write("<script language=\"javascript\">window.open('" + url+ "','SportZip',toolbar='0,scrollbars=-1,resizable=-1');void(0);</script>");

                }
     Server.Transfer("Step2.aspx");

Page 1 of 1 (13 items)