tabs - C# - Programmatically Opening a Pop-Up Window in Browser -


i have following code:

if (function.equals("popup"))             {                 request req = new request();                 string result = req.dorequest("function=" + function + "&num=" + trans_number, "http://localhost:4000/handler.ashx");                  if (result.equals("true") || result.equals("true"))                 {                     page.clientscript.registerstartupscript(page.gettype(), null, "window.open('http://localhost:4000/transaction_number.aspx', '_newtab')", true);                 }                  session["result"] = result;                 response.redirect("results.aspx");             } 

this code makes request server , if result true, should create new tab redirect current window results.aspx.

if result false, should redirect results.aspx.

the main problem code new tab never created, if result true. however, if comment out of code except new tab code, new tab created.

why happening? how can correct it?

the problem seems you're redirecting before script can execute. try doing redirect in script too, this;

if (function.equals("popup")) {     request req = new request();     string result = req.dorequest("function=" + function + "&num=" + trans_number, "http://localhost:4000/handler.ashx");      if (result.equals("true") || result.equals("true"))     {         page.clientscript.registerstartupscript(page.gettype(), null, "window.open('http://localhost:4000/transaction_number.aspx', '_newtab')", true);     }      session["result"] = result;      page.clientscript.registerstartupscript(page.gettype(), null, "window.location.href = 'http://localhost:4000/redirect.aspx.aspx'", true); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -