470,602 Members | 1,646 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

open new browser window from server

I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing
page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen.
Anyone found the solution??

MTIA
wardeaux
Nov 18 '05 #1
6 4002
You won't be able to do that from the server. You'll have to do this on the client-side with javascript. Write it out to the page somewhere on the response.

"Wardeaux" <wa******@bellsouth.net> wrote in message news:ed**************@TK2MSFTNGP10.phx.gbl...
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing
page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen.
Anyone found the solution??

MTIA
wardeaux

Nov 18 '05 #2
Wardeaux wrote:
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing
page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen.
Anyone found the solution??

MTIA
wardeaux


You have to insert some Javascript to popup the new window when loaded,
since the server has no concept of a 'client window'.

Here's an example of how to inject the script, replace the alert with
whatever you're trying to do.

http://searchvb.techtarget.com/vsnet...293672,00.html

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #3
Use RegisterStartupScript method in your codebehind to register a client side window.open javascript call.

It will be rendered as the page reloads and when the browser encounters the javascript code it will execute it.

http://msdn.microsoft.com/library/de...BlockTopic.asp

HTH,
Suresh.

"Wardeaux" wrote:
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing
page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen.
Anyone found the solution??

MTIA
wardeaux

Nov 18 '05 #4
Craig,
thanks! :)
wardeaux
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
Wardeaux wrote:
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen. Anyone found the solution??

MTIA
wardeaux
You have to insert some Javascript to popup the new window when loaded,
since the server has no concept of a 'client window'.

Here's an example of how to inject the script, replace the alert with
whatever you're trying to do.

http://searchvb.techtarget.com/vsnet...293672,00.html
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #5
Suresh,
thanks! Any way to keep that script from running EVERY time the page is
loaded like when you hit either the "Back" or "Refresh" button?
wardeaux

"Suresh" <Su****@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Use RegisterStartupScript method in your codebehind to register a client side window.open javascript call.
It will be rendered as the page reloads and when the browser encounters the javascript code it will execute it.
http://msdn.microsoft.com/library/de...BlockTopic.asp
HTH,
Suresh.

"Wardeaux" wrote:
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen. Anyone found the solution??

MTIA
wardeaux

Nov 18 '05 #6
Refresh will cause a page load. Since the window.open is registered on postback the script shouldn't be registered on page load.

As for when the user presses the browser back button?
That's a drawback of using RegisterStartupScript method.

Suresh.

"Wardeaux" wrote:
Suresh,
thanks! Any way to keep that script from running EVERY time the page is
loaded like when you hit either the "Back" or "Refresh" button?
wardeaux

"Suresh" <Su****@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Use RegisterStartupScript method in your codebehind to register a client

side window.open javascript call.

It will be rendered as the page reloads and when the browser encounters

the javascript code it will execute it.

http://msdn.microsoft.com/library/de...BlockTopic.asp

HTH,
Suresh.

"Wardeaux" wrote:
I can't find a way to open a new browser window from my codebehind.

1) My page does a postback to the server.
2) On server I evaluate whether to return to existing page or leave existing page displayed and open new window with different page

Seems easy enough, I've just not found the key element to make this happen. Anyone found the solution??

MTIA
wardeaux


Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by lukeo | last post: by
6 posts views Thread by qysbc | last post: by
6 posts views Thread by Charlie Garrett-Jones | last post: by
2 posts views Thread by H. Rodriguez | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.