View Full Version : Add an attribute to the <BODY>

03-01-2007, 07:36 PM
I want to do an action which causes a postback. The postback checks to see if the action took place. If it did, I want to add an "onload" to the <BODY>. How do I do this?

The following code will put the attribute in the <FORM>, but it doesn't fire on the postback load.

Page.Form.Attributes.Add("onload", "OpenFile();")

There is no "Me.Attributes.Add" - that would be nice.

03-01-2007, 08:07 PM
Why put it there when it belongs in the Javascript code.

window.onload = OpenFile;

03-01-2007, 08:09 PM
Because if my action took place, I want to add this function to fire off on my BODY onload on the postback. However, I need to add the onload attribute to the BODY tag. I don't want it to always fire off, only after my "action" has taken place.