add <body onunload="blah();">

O

Oleg Ogurok

Hi all,

Is there a way to add a client side onunload statement into the <body> tag
of a page?
Thanks.

-Oleg.
 
C

Curt_C [MVP]

I wouldn't waste your time, it's not reliable.
Also, it's not an ASP(X) issue at all since it would never make the second
trip.
 
C

Carl Prothman [MVP]

Oleg said:
Is there a way to add a client side onunload statement into the
<body> tag of a page?

Sure, just add an ID and Runat attribute to the BODY tag.
e.g.
<BODY id="Body1" runat="server">

Then in the code-behind file, add a class var such as
protected System.Web.UI.HtmlControls.HtmlGenericControl Body1;

Then in the Form_Load event, add the client-side client event handler
Body1.Attributes.Add("onUnload", "Body1_OnUnload");

Or course you will need the client-side script to handle the onUnload
event. ;-)
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top