How to call a Javascript function in VB?

  • Thread starter Thread starter prince -=nore=-
  • Start date Start date
P

prince -=nore=-

I'm trying to open a new window when a button is clicked.
I'm using the following code in my page_load to do so.




Dim myScript As String = "<script language=javascript> function
loadWin() {"

myScript += "window.open('testl.aspx')"

myScript += "}</" + "script>"

Page.RegisterStartupScript("OpenWindowScript", myScript)




What I want to know, is how to refer or call that function in VB.
 
You could use RegisterStartupScript to ensure your client side function gets called as soon as the page loads into the browser.

Here's more info:
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp


But you cannot call a client side function directly from server side code.



You can use a bit of HTML like this to link your client side code with a client side event:

<BUTTON id="mybutton" onclick="loadWin"

name="mybutton" type="button" value="Button">

Click Me</BUTTON>


Here's information on how to do that dynamically:
Attributes.Add:
http://www.flws.com.au/showusyourcode/codeLib/code/NET_jsAddTo.asp?catID=5
 
Back
Top