I have a requirement to open a new popup by using window.open and redirecting my current page to new page. My code looks something like below:
// Work done...
// RegisterStartupScript("window.open("page1.aspx")");
// Server.Transfer("page2.aspx");
The problem is that my page is being redirected to page2.aspx but not opening a popup for page1.aspx.
It opens popup when Server.Transfer is not used.
Please guide me how I can achieve it?
Server.Transfer does not send the response back to the browser and hence your javascript code would not execute. If you want to execute the javascript and then redirect the response use Response.Redirect.
Please read the difference between both these methods here http://haacked.com/archive/2004/10/05/responseredirectverseservertransfer.aspx
Also, Server.Transfer can only transfer to an asp.net page in the same
application. When you call Server.Transfer, it just creates an instance of
the specified page and transfers page processing from the current page to
the new page.