setting <body> attributes

  • Thread starter Thread starter James Cooke
  • Start date Start date
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
 
You can assign a id and the runat="server" attribute to
the body tag and access it in your code as
HtmlGenericControl.

Tu-Thach
 
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)
 
Back
Top