|
|
A user recently on the asp.net forums asked a question on linking the ImageButton to a URL. The requirement was to navigate the user to a URL when the ImageButton was clicked. Here’s how to do so using the OnClientClick()
<asp:ImageButton ID="ImageButton1" runat="server"
src="images/icon260.jpg" onmouseover="this.src='images/emo.jpg'"
onmouseout="this.src='images/icon260.jpg'" CauseValidation="false"
OnClientClick="document.location.href = 'http://www.dotnetcurry.com';
return false" />
Remember to use the OnClientClick() and not the OnClick() event of the ImageButton. The OnClick() event is a server side event.
Alternatively, it’s easier to use a HyperLink control and set it's ImageUrl to an image and set NavigateUrl to the URL you want.
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
0 Responses to "How to Navigate to a URL on clicking the ASP.NET ImageButton"Post a Comment