Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   CustomControl and body.onload (http://www.velocityreviews.com/forums/t777763-customcontrol-and-body-onload.html)

Ernest Morariu 03-22-2006 01:22 PM

CustomControl and body.onload
 

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



CaffieneRush@gmail.com 03-22-2006 06:06 PM

Re: CustomControl and body.onload
 
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



All times are GMT. The time now is 04:42 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.