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..