Last post Jul 12, 2014 12:19 AM by AppDevForMe
Jul 11, 2014 12:35 AM|AppDevForMe|LINK
If I create an Asp.net button on the server side in C# I can have it call a java script method named "flipAndSwitch" when it is pressed.
Button btn = new Button(); btn.ID "MyBtn"; btn.OnClientClick = "return flipAndSwitch(this);";
So how can I call a java script method if I create a HyperLink button in C#.
As far as I can tell, there is no OnClientClick method.
Hyperlink hl = new HyperLink(); // Now how do I have the hyperlink call a java script method when the hyperlink is pressed?
Jul 11, 2014 12:47 AM|mike4u|LINK
<asp:HyperLink ID="HyperLink4" runat="server" onclick="logDownload();" NavigateUrl="~/download/Sample-Icons.zip">Download Icons</asp:HyperLink>
Jul 11, 2014 12:54 AM|PawanPal|LINK
You should try OnCLientClick event of heyperlink as below.
<asp:HyperLink ID="Hyperlink" runat="server" OnClientClick="JsFunction(this.src)" />
Jul 11, 2014 08:15 AM|AppDevForMe|LINK
Thanks to both of you. I actually need to create the hyperlink control on the server side using C#, like in my example. It is a requirement, since I am having to insert it into a repeater control. Can either of you, or someone show me how to do this on the
Jul 12, 2014 12:19 AM|AppDevForMe|LINK
I think the Asp.net LinkButton will work. Thanks everyone.
l = new