Script in body

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I know that I can use the following code to add some script-code to a button
button.Attributes("onclick") = myscript
I like to do the same for the page itself as ("onload") = "myjavascriptfunction();
Which element do I need to use? me.Attributes("onload") is not possible

Thanks a lo

Joy
 
Try this:

1. Give the <body> tag an id, and make it run as a htmlcontrol

<body id="myBody" runat="server">

2. In your code-behind, create a reference to the body object, and attach the
function you need to the "onload" event.

Protected WithEvents myBody As
System.Web.UI.HtmlControls.HtmlContainerControl

body.Attributes("onload") = "myjavascriptfunction();"

Tommy,
 
Back
Top