new "windows" in .NET

  • Thread starter Thread starter Stuart Brierley
  • Start date Start date
S

Stuart Brierley

Does anyone have any ideas how to open a new web browser
window in .NET?

I'm using ASP.NET with VB as the code behind, and after
some (server side) validation code may need to open a
second browser window.

Any help gratefully received.

Cheers
Stu.
 
You do just like you would in HTML: put a client-side script with a
windows.open(...) command.

ASP.Net doesn't provide you with anything new on that side.
 
In your codebehind after the validation write the
javascript to open the window to a literal control.

litScript.Text = "<script
type=""text/javascript"">window.open('somepage.aspx');
 
Hi,

Thanks for the reply.

I already knew of the windows.open() command, but I don't
know of a way that I can invoke this from my VB code.

Is there a way to invoke the java script from the VB
server side code?

Cheers
Stu.
 
I already knew of the windows.open() command, but I don't
know of a way that I can invoke this from my VB code.

Is there a way to invoke the java script from the VB
server side code?

In your CodeBehind, write:
RegisterClientScriptBlock("<script>window.open(...)</script>");
 
Thanks, that is exactly the kind of functionality I was
looking for.

With a bit of thought I can now achieve my goal.

Cheers
Stu.
 
Hi Stuart,

An ASP.Net application is just HTML on the client side. Therefore, the way
to open a new browser window is still the same. You can do it either by
using the "target" attribute of a hyperlink or form, or you can use
JavaScript's window.open() method to do so. In either case, it has to be
done on the client browser, not on the server (other than, for example,
using Page.RegisterStartupScript() to add your JavaScript to the page).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Okay, what would you say if I want this page to open a new
window and THEN go to a different page itself?
 
Okay, what would you say if I want this page to open a new
window and THEN go to a different page itself?

litScript.Text = "<script>window.open('somepage.aspx');
window.location='otherpage.aspx'</script>"



This kind of question would be better asked on a JavaScript forum...
 
The example supplied below opens the new window when the
original page "reloads".

In my application I have a small java function which I
call (rather than directly calling window.open()).

Could you not set the literal to call a java function
which first calls window.open and then redirects the
original page itself?

Would that work?

Cheers
Stu.
 
Back
Top