Click here to Skip to main content
14,937,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is a asp image button and when i click it,it redirects to another page. I want to disable that image button untill it redirect to given page.

Perera wrn
Updated 6-Jun-13 1:28am

1 solution

<asp:button id="MyButton" runat="server" text="Redirect" />

In code behind:
MyButton.Attributes.Add("onclick","return RedirectToAnotherPage();");

Write the following function in the head section of your page:
function RedirectToAnotherPage()
document.getElementById('MyButton').disabled = true;
 window.location.href=""; [EDITED]
return true;
Mike Meinz 6-Jun-13 7:19am
My vote of 5.

This should be De-Facto Standard:
Always disable a clickable item on first click

When an eCommerce web site makes a statement that says something like only click once so your order will not be duplicated, you know the site developers did not follow this De-Facto Standard.
Zafar Sultan 6-Jun-13 7:20am
Indeed. Thanks.
Thanks7872 6-Jun-13 7:30am
↑voted....This answer needs to be appreciated..!
Zafar Sultan 6-Jun-13 8:07am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900