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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top