Forum Moderators: open

Message Too Old, No Replies

Added attribute to <BODY>

         

jleone

6:37 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



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.

TheNige

8:51 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



put a runat=server on your body tag, give it an ID and then you can set the attributes on the codebehind. You can dimension the control as a generic HTML control object I think.

Another better option may be to use RegisterClientScript or RegisterStartupScript. If you are using .Net 2.0 then check out the ClientScript namespace.

[edited by: TheNige at 8:53 pm (utc) on Mar. 1, 2007]