How to get reference of the <body runat=server id=.../> on server side?

F

feng

I need to add an "onload" attribute to <body> tag so that
I can insert client side JavaScript when the page is
reloaded. It looks like I should be able to get a
reference to the <body> control as it takes
a "runat=server" attribute. But I still don't know how to
define this body control in code behind. Can someone show
me how to do this?

Thanks
 
P

Peter Rilling

1) Give the body tag a unique ID.
2) In the code-behind, declare an instance variable that can map to the tag
(protected HtmlGenericControl myBodyTag;) where the name of this variable is
the same as the tag ID.

Now you should be able to manipulate the <body> tag by using the methods and
properties on the variable.
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top