473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Open new browser window in vbscript.net

hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #1
9 3133
Heres an example aspx page for you that shows you how to do it in vb.net.
This works in VWD.

<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)

Dim scriptString As String
scriptString = "<script language=JavaScriptfunction DoClick() {"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If

End Sub

</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"smokeyd" <to********@umbro.co.ukwrote in message
news:11*********************@79g2000cws.googlegrou ps.com...
hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #2
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,
scriptString = "<script language=JavaScriptfunction DoClick() {"
That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)
Dec 21 '06 #3
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,
> scriptString = "<script language=JavaScriptfunction DoClick() {"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)

Dec 21 '06 #4
Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net. uk...
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net .uk...

Hi John,
>> scriptString = "<script language=JavaScriptfunction DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)


Dec 21 '06 #5

John Timney (MVP) wrote:
Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not ClientScript.IsClientScriptBlockRegistered("Client Script"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net. uk...
fair comment.....I'll change the source example so next time I post it its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net. uk...

Hi John,

scriptString = "<script language=JavaScriptfunction DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick() {"

Mark

P.S. Not a problem if you don't need cross-browser compatibility... ;-)
thanks for all of the help. the code needed a few little tweaks but
works great:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick() {"
scriptString +=
"window.open('popup.aspx','MyWindow','width=500,he ight=500');}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.IsClientScriptBlockRegistered("Client Script")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server"
OnClick="DoClick()" NavigateUrl="#"HyperLink</asp:HyperLink></div>
</form>
</body>
</html>

however visual web developer gives an error saying onclick is not a
valid attribute of element 'hyperlink' but seems to work okay anyway..

Dec 21 '06 #6
http://www.dotnetjohn.com/articles.aspx?articleid=88

"smokeyd" <to********@umbro.co.ukwrote in message news:11*********************@79g2000cws.googlegrou ps.com...
hi,

can anyone tell me how to open a link in a new browser window in
vbscript.net. i am looking to be able to set the properties such as
size, menu bar, scroll bar etc. or alternativelly is there a simple
way to do this in visual web developer?

many thanks in advance for your help.

Dec 21 '06 #7
Change your hyperlink declaration to:

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>

and your warning should go away.....
Regards
John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"smokeyd" <to********@umbro.co.ukwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
>
John Timney (MVP) wrote:
>Just for clarity in the thread - for VB.NET the code is
scriptString = "<script type=""text/javascript""function DoClick() {"

Full example below:
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load( sender as Object,e as EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick()
{"
scriptString +=
"window.open('http://www.mvps.org','MyWindow','width=500,height=500');} <"
scriptString += "/"
scriptString += "script>"

If (Not
ClientScript.IsClientScriptBlockRegistered("Clien tScript"))
Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>

<html>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:dI******************************@eclipse.net .uk...
fair comment.....I'll change the source example so next time I post it
its
covered :)
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TO******************************@eclipse.net .uk...

Hi John,

scriptString = "<script language=JavaScriptfunction
DoClick()
{"

That syntax is deprecated now, and won't produce XHTML-compliant
markup.

Use this instead:

scriptString = "<script type=\"text/javascript\"function DoClick()
{"

Mark

P.S. Not a problem if you don't need cross-browser compatibility...
;-)

thanks for all of the help. the code needed a few little tweaks but
works great:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim scriptString As String
scriptString = "<script type=""text/javascript""function
DoClick() {"
scriptString +=
"window.open('popup.aspx','MyWindow','width=500,he ight=500');}<"
scriptString += "/"
scriptString += "script>"
If (Not
ClientScript.IsClientScriptBlockRegistered("Client Script")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType( ),
"ClientScript", scriptString)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server"
OnClick="DoClick()" NavigateUrl="#"HyperLink</asp:HyperLink></div>
</form>
</body>
</html>

however visual web developer gives an error saying onclick is not a
valid attribute of element 'hyperlink' but seems to work okay anyway..

Dec 21 '06 #8
John Timney (MVP) wrote:
>>Change your hyperlink declaration to:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>

or..... if you want to use the onlclick event in page_load add this:

HyperLink1.attributes.add("onclick", "DoClick()")

Alexander Higgins
http://www.affordablewebdesignsinc.com

Dec 21 '06 #9
Yes, you can do that of course.

The hyperlink declaration should be changed to:

<asp:HyperLink ID="HyperLink1" NavigateUrl="#" runat="server" >
HyperLink</asp:HyperLink>

A quirk with using attributes.add - If you dont set the NavigateUrl property
and dont style it you will get a plain old clickable word.

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Alexander Higgins" <al************@hotmail.comwrote in message
news:11*********************@79g2000cws.googlegrou ps.com...
John Timney (MVP) wrote:
>>>Change your hyperlink declaration to:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="javascript:DoClick()"HyperLink</asp:HyperLink>


or..... if you want to use the onlclick event in page_load add this:

HyperLink1.attributes.add("onclick", "DoClick()")

Alexander Higgins
http://www.affordablewebdesignsinc.com

Dec 22 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Eaton | last post by:
Hi I am developing my first asp appication (vbscript). I am storing cheques scans (in pdf format) in the file system along with the db on the server. The following code is working without...
0
by: amita | last post by:
hi, 1.I want to show a image file of type '.tif' in the browser window; for that I'm writting as ASP code page. 2.This '.tif' type image can be shown better with 'Kodak Image Control'. 3.To...
1
by: Krechting | last post by:
Hi All, I need a button on my form that opens a new window. I put in a submit button but it always returns to my first page. And then my first page is empty. What button do I need to go to...
6
by: n2K | last post by:
Hello to all. I would like to open a new window (Function is called NewWindow and is writtent in VBscript) when a user submits a form. All the samples I found on the web indicate something like the...
5
by: David | last post by:
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...
1
by: msnews | last post by:
I have a button on an asp.net page that has the following code.. machinename = TextBox1.Text Response.Redirect("remote.asp?machinename=" & machinename) I couldn't figure out how to lauch...
0
by: thomas | last post by:
I found John Viescas's book "Access2003 Inside and Out" most helpful especially the section on Data Access Pages, and as such I have successfully launched a Intranet Web site whereby 4 remote sites...
3
by: frank | last post by:
There are some methods for redirect to another aspx page. response.redirect() server.transfer() Is it possible to open a new browser window which is not using javascript. Thanks!
6
by: Jeff | last post by:
hey guys, this may not be the right place, but i wanted to give it a shot. i have an if statement, based on the data of a mssql db. if the if is .eof do nothing else
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.