|
-
Aug 14th, 2002, 06:25 PM
#1
Thread Starter
Hyperactive Member
Opening another browser
How do I open another browser window when a user clicks on a button?
I don't seem to have the Window object (I don't want to use JavaScript if at all possible)
Thanks!!
-
Aug 15th, 2002, 03:38 AM
#2
Member
Since there's no physical connection between client and server I imagine even if there is a neat way of doing it, behind the scenes some client-side scripting would be used. Just like when using autopostback with a listbox.
The way I do this is have in the ASPX file...
<script language="vbscript">
Sub BrowseNewWindow(URL)
window.open URL, "NewWindow"
End Sub
</script>
And then on the code-behind for server-side, create the sub routine...
Private Sub OpenNewWindow(ByVal URL As String)
RegisterStartupScript("BrowseScript", "<script language=""VBSCRIPT"">BrowseNewWindow(""" & URL & """)</script>")
End Sub
And then on any click event, you can use...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenNewWindow("http://www.google.co.uk")
End Sub
This automatically adds the script block which will execute as soon as the page is loaded in the browser. Although its still using scripting, I think its neater than having a load of script added to the ASPX page.
-
Aug 21st, 2002, 04:49 PM
#3
Thread Starter
Hyperactive Member
I have added the script to my .ASPX page and the code behind method, but when I click the button nothig happens. I steped through the execution and it is firing the RegisterStartupScript it's just not doing anything on the client end.
Thanks!!
-
Aug 21st, 2002, 04:56 PM
#4
Thread Starter
Hyperactive Member
I found a much easier way to do this...
Code:
response.write("<script language=javascript>window.open(URL, TARGET='another');</script>")
http://asp.net/Forums/ShowPost.aspx?...1&PostID=33382
Thanks for the help!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|