Home All Groups Group Topic Archive Search About
Author
22 Mar 2006 1:22 PM
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

Author
22 Mar 2006 6:06 PM
CaffieneRush@gmail.com
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