Saturday, May 11, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  110] [ 1]  / answers: 1 / hits: 28953  / 15 Years ago, thu, april 16, 2009, 12:00:00

I want to disable a LinkButton clink on the client site.



objLinkButton.disabled = true;
// or
objLinkButton.disabled = -1;


This disables the link but I am still able to click on the link and do PostBack.



Is there any way I can disable the link.



Code:



<asp:linkbutton id=xyz runat=server
onClick=javascript:LinkDisable(this) ></asp:linkbutton>


which renders as a link which does a postback... I am opening the page on postback in a new window.
What I want to do is.. when I click on the link for the firsttime.. it will open a new page and then it will disable the link.



what I am doing is .. onClick of that link I have a javascript function.. which is something like this..



In LinkDisable ...



function LinkDisable(obj)
{
obj.disabled = -1;
obj.href = '#';
//Cant return false from here.. otherwise it wont postback...
}


When I do this.. the link gets grey's out ... but I am still able to click it. I want to stop the user from clicking it the second time.



Any help is appreciated.


More From » c#

 Answers
16

Found the Solution guys... these javascript solution will work but if you refresh the page... it will clear the varaibles.



So thats a bug right there..



Found the solution using userData ... IE Session data... it really cool.



Checkout this link:http://www.eggheadcafe.com/articles/20010615.asp


[#99699] Wednesday, April 8, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
larrycodys

Total Points: 394
Total Questions: 93
Total Answers: 78

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;