CustomControl and body.onload

E

Ernest Morariu

Hi All !

I subclassed a Label control(ASP2.0) .
How to modify(form inside my control) the attribute onload of the <body> of
the page where my control resides?

I need the browser to execute a javascript function(when the page loads)
that my control registers with ClientScriptManager.

Ernest
 
C

CaffieneRush

Here's a method that I would personally NOT used butmight suit your
needs.

1) Make the page body tag of a server control.
i.e.
<body id="body1" runat="server">
....
</body>
2) Use FindControl() to find the body within the subclass and inject
your javascript.
The subclassed OnLoad handler might be a good location to do this.
i.e
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Dim body As HTMLGenericControl =
Me.Page.FindControl("body")
body.Attributes.Add("OnLoad",
"javascript:document.bgcolor='red'")
End Sub
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top