L
Laurent Bugnion
Hi,
I am trying to programatically add an "onunload" event handler to the
"body" tag of an ASPX page. I am doing this from a Custom Control
located on this page.
To do this, I added "runat=server" to the body tag, which provides me
access to it in the code-behind through a HtmlControl. I can then
manipulate the Attributes collection, which is what I needed. So far so
good.
However, I found out that "runat=server" generates a compilation error
(CS1012: Too many characters in character literal) if the "body" tag
already has an onunload event handler (in the ASPX code). This is a
problem, because I wish that the user of my custom control be free to
specify event handlers in the body tag, and my control should simply add
its own.
So the question is: Is there a way to use "runat=server" on a body tag
with an onunload event handler?
I am using the framework 1.1.
Unfortunately, there are no "RegisterEndScript" methods (similar to
"RegisterStartupScript") in the Page class ;-)
Thanks,
Laurent
I am trying to programatically add an "onunload" event handler to the
"body" tag of an ASPX page. I am doing this from a Custom Control
located on this page.
To do this, I added "runat=server" to the body tag, which provides me
access to it in the code-behind through a HtmlControl. I can then
manipulate the Attributes collection, which is what I needed. So far so
good.
However, I found out that "runat=server" generates a compilation error
(CS1012: Too many characters in character literal) if the "body" tag
already has an onunload event handler (in the ASPX code). This is a
problem, because I wish that the user of my custom control be free to
specify event handlers in the body tag, and my control should simply add
its own.
So the question is: Is there a way to use "runat=server" on a body tag
with an onunload event handler?
I am using the framework 1.1.
Unfortunately, there are no "RegisterEndScript" methods (similar to
"RegisterStartupScript") in the Page class ;-)
Thanks,
Laurent