how to open a new browser windows using asp.net code?

D

David

Hi

I don't want to use javascript to open a new window because I want to use
server side code which gives me more control. I think I can not use
response.redirect to open a new window and keep the current window.
Is there any way to do it?

Thank you!

David
 
W

William F. Robertson, Jr.

You can not force a client to open a new browser window without having some
client side script (javascript or vbscript) from the server. So the answer
to your question is no.

What more control do you think you would have from the server anyway?

Also, you have no control from the server side, so client side will give you
much more control.

bill
 
D

David

Hi Bill
Thanks a lot.

My problem is I want to execute some server side code first (checking the
validity of passing values), then open a new window when the user click the
open new window button.
 
B

Bryce Budd

David,

The simple solution is to combine the both.

Here's an example scenario.

Create a literal control call litJavaScript on your webform.

In your event that processes your data server-side perform your validation
(or whatever you're doing). Then
add the following:

String js = "<script
langauage='javascript'>window.open('url.aspx')</script>";
litJavaScript.Text = js;

When the page renders the javascript will run and execute your open window
call.

Good luck
Bryce
 
D

Daniel Walzenbach

David,

Check out the RegisterStartupScriptBlock/RegisterClientScriptBlock functions:

e.g.
dim myScript as string = "<script language=javascript>alert('MyMessage');</script>";
Page.RegisterClientScriptBlock("MyScript", myScript)

enter this code in your event

Greetings

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top