setting <body> attributes

J

James Cooke

I want to set body attributes programmatically, from the module file:
I can go into the .aspx file and say <body onload="myFunc()"> but I don't
want to.

Like you do with a textbox control:

txtCustomer.Attributes("onblur") = "myFunc()"

I would like to do the same with the <body> tag.

Any ideas?
Thanks
 
T

Tu-Thach

You can assign a id and the runat="server" attribute to
the body tag and access it in your code as
HtmlGenericControl.

Tu-Thach
 
B

bruce barker

if you run framework 1.1 you're in luck:

<body runat="server" id="body">

in code behind

HtmlGenericControl ctl = Page.FindControl("body") as HtmlGenericControl;
if (ctl != null)
ctl.Attributes.Add("onclick","alert('hi')");


-- bruce (sqlwork.com)
 

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,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top