Friday, October 19, 2007

Calling Javascript Function from Code Behind(.vb)

This is the function at html page:

<script language="javascript">
   function test(){
      //Add the function code here
   }
</script>

To call this javascript function from code behind(.vb), Use Page.RegisterStartupScriptfunction like the following code:

Dim strScript As string = "<script language='javascript' id='myClientScript'>test();</script>"
Page.RegisterStartupScript("callTest", strScript)

No comments: