Welcome Guest Search | Active Topics | Sign In | Register

Grid Paging & onbeforeunload Options
Vinny
Posted: Friday, May 21, 2010 3:35:30 PM
Rank: Advanced Member
Groups: Member

Joined: 7/21/2008
Posts: 90
Hi,

I've problem related to Grid Paging.

In our application we are calling onbeforeunload function in the body tag. Now, what happening is that when ever I click the Page Number in the EO grid the onbeforeunload function gets called. I don't know how to overcome this problem and will appreciate if you guys can assist in this.

Thanks,

Vinny
eo_support
Posted: Sunday, May 23, 2010 1:15:34 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The root of the problem is onbeforeunload is fired whenever a HTML link is clicked. For example, onbeforeunload is fired when the following link is clicked:

Code: HTML/ASPX
<a href="AnotherPage.aspx">leave current page and go to another page</a>


However it is also fired when the following link is clicked:

Code: HTML/ASPX
<a href="javascript:SayHello();">Say Hello!</a>


The problem is not particular to our Grid but to all HTML links. For example, you will see the same problem with a standard ASP.NET LinkButton control.

There is no "official" solution for this problem as we are aware of. One way is to scan all A elements in your page and track their onclick event, based on the assumption that onclick event is fired shortly before onbeforeunload event. You will then set a flag in your onclick handler to mark a link has just been clicked and check that flag in your onbeforeunload handler to identify whether it is really a link that tries to navigate away. If it is not, then you skip your normal unbeforeunload logic. However not only this is quite some extra work, but our experience also indicates that it does not always work reliably.

Thanks!
Vinny
Posted: Friday, May 28, 2010 5:12:33 PM
Rank: Advanced Member
Groups: Member

Joined: 7/21/2008
Posts: 90
Thanks. Your suggestion helped.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.