adsense

Wednesday, March 25, 2015

Disable the Asp.Net linkbutton

When you working with the Asp.Net link button, you might have noticed that even though you have disabled it (Enabled = false) the user still can click the link.

It is not as straightforward as you might have expected to completely disable the link button. Use the following code snippet achieve the desired effect.


lnkBtn.Attributes.Remove("href")
lnkBtn.Attributes.CssStyle(HtmlTextWriterStyle.Color) = "gray"
lnkBtn.Attributes.CssStyle(HtmlTextWriterStyle.Cursor) = "default"
lnkBtn.Font.Underline = False ' used to remove the underline effect when mouse-hover

Cheers
Samitha