Last post Mar 08, 2011 07:01 PM by helpjet
Mar 08, 2011 07:01 PM|helpjet|LINK
Attaching "OnClick" event to <asp:menu.../> menu item.
back and waiting ..)
Here is the html
document.getElementById('menuWaiter').style.display = 'inline';
<img id="menuWaiter" src="/CStore/Images/processing.gif" alt="" style="display:none"/>
<asp:Menu ID="menuMain" runat="server".../>
//I used SiteMapDataSource to bind this control
var varMenuMain = '<%= menuMain.ClientID %>'
var elements = document.getElementById(varMenuMain).getElementsByTagName('a');
for (var i = 0; i < elements.length; i++)
if(elements[i].href != "")
if (navigator.appName == 'Microsoft Internet Explorer')
elements[i].addEventListener('click', Animation, false)
There are two script sections, one in the head and one at the end (but before the page ends). <asp:menu ...> is rendered as "div" and all its menu items are rendered as anchors "a".
This technique works when you have to do full post back and the connection is slow or service response time is higher. While the client is waiting for the fresh page, client browser will show the animation.