Last post Sep 26, 2011 08:46 AM by TL
Mar 25, 2010 01:55 PM|Chrissteven81|LINK
*this reffers to the linkbutton
Problem: when you run the following code it disables the look of the link however not the click event.
this.disabled = false;
first solution i found was to change the href first i tried changing the href to "" this disabled the click event however i could not reenable it. Even after reseting the href the button would not fire the postback.
Finally i figure out that i could do the following
Dim LinkButton As LinkButton = DirectCast(sender, WebControls.LinkButton)
LinkButton.Attributes.Add("onClick", "return !this.disabled;")
This code allowed me to set the event serverside and control it using the disabled property of the linkbutton class in my client side code.
I hope this helps the people that may run into the same issue as i did.
in Firefox you have to also change the css class to look like a disabled link otherwise users will be clicking and not understanding why nothing is happening
found a minor issue with this method. disabled is not a property of an anchor tag in firefox. this does not effect functionality if you set disabled property before you attempt to use it. im not sure/concerned if this is w3 standards complient as long as
it works on each browser and it seems to do so.
Dec 21, 2010 06:14 AM|MTalha|LINK
Sep 26, 2011 08:46 AM|TL|LINK
At last!!! solution that works!
Thank you so much!