"OnClick" does work but, the java script that I am using is for slow page loads. The java script shades the web page and show a message box saying "Please wait page is loading....". When I use the
"OnClick" it shades the web page and shows the message box, but does not disappear after the new page is done loading. The "OnClientClick" does shade the web page and shows the message box and then
does show the new page when it is done loading.
"OnClick" does work but, the java script that I am using is for slow page loads. The java script shades the web page and show a message box saying "Please wait page is loading....". When I use the
"OnClick" it shades the web page and shows the message box, but does not disappear after the new page is done loading. The "OnClientClick" does shade the web page and shows the message box and then
does show the new page when it is done loading.
At the runtime, there is no property called OnClientClick. It will render as onclick. In other words, raw HTML controls does not have an attribute called OnClientClick. OnClientClick is just an attribute provided by asp.net server controls to make the task
easier and convenient. Every control will render as HTML controls, so adding onclick attribute is the way to run the javascript even in asp.net controls.
jeffrijo
Member
22 Points
27 Posts
How do I do a "OnClientClick" for a navigation menu?
Apr 29, 2012 08:44 PM|LINK
How do I do a "OnClientClick" for a navigation menu?
thanks,
Ruchira
All-Star
42943 Points
7024 Posts
MVP
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 10:34 AM|LINK
Hello,
First of all, make sure callMyJavaScript method is accessible from the page. Then try the below code
Menu
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.jeffrijo
Member
22 Points
27 Posts
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 12:47 PM|LINK
Hi,
There is no menu.OnClientClick method. If there was that would solve my problem. The code works for all my buttons and links:
<asp:ImageButton ID="imgMyMessages" runat="server" ImageUrl="~/Images/App/Icon_Messages.jpg" onclientclick="callMyJavaScript();" PostBackUrl="~/Messages/ReadMessage.aspx" />
I just can not find a way to call OnClientClick from the menu control.
Any ideas would be greatly appreciated!
Thanks,
Menu
Ruchira
All-Star
42943 Points
7024 Posts
MVP
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 01:03 PM|LINK
Hi,
Sorry. It was just a wild guess. Can you test the below code?
Menu.Attributes.Add("onclick","callMyJavaScript();");
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.jeffrijo
Member
22 Points
27 Posts
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 01:36 PM|LINK
"OnClick" does work but, the java script that I am using is for slow page loads. The java script shades the web page and show a message box saying "Please wait page is loading....". When I use the "OnClick" it shades the web page and shows the message box, but does not disappear after the new page is done loading. The "OnClientClick" does shade the web page and shows the message box and then does show the new page when it is done loading.
Thanks,
Ruchira
All-Star
42943 Points
7024 Posts
MVP
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 01:45 PM|LINK
At the runtime, there is no property called OnClientClick. It will render as onclick. In other words, raw HTML controls does not have an attribute called OnClientClick. OnClientClick is just an attribute provided by asp.net server controls to make the task easier and convenient. Every control will render as HTML controls, so adding onclick attribute is the way to run the javascript even in asp.net controls.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.jeffrijo
Member
22 Points
27 Posts
Re: How do I do a "OnClientClick" for a navigation menu?
Apr 30, 2012 04:59 PM|LINK
I tried the "OnClick" again and it is working now!
Thanks!