Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomControl and body.onload

Reply
Thread Tools

CustomControl and body.onload

 
 
Ernest Morariu
Guest
Posts: n/a
 
      03-22-2006

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


 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-22-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomControl Losing Events. Ashish ASP .Net 0 05-22-2006 03:26 PM
ImageButton Click Event in CustomControl =?Utf-8?B?U3RldmU=?= ASP .Net 2 02-20-2006 06:15 PM
writing a customControl philipp ASP .Net 2 05-18-2005 03:40 AM
A HtmlControl as Customcontrol Property KMILO ASP .Net 0 04-22-2005 09:17 PM
CustomControl - Not triggering on an empty field. Eric B ASP .Net 1 09-03-2003 09:24 AM



Advertisments