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
Post a Comment