Saturday 30 August 2008

ASP.NET LinkButton without JavaScript

If you use ASP.NET LinkButton controls, the client browser must have JavaScript enabled. If JavsScript is disabled, clicking on the link won't cause a postback. To avoid this scenario, use standard Button controls and style them to look like hyperlinks.

Example:
<asp:Button runat="server" CssClass="HyperlinkButton" Text="Submit" />

CSS:
.HyperlinkButton
{
background: none;
border: none;
cursor: pointer;
text-align: left;
}

.HyperlinkButton:hover
{
text-decoration: underline;
}

4 comments:

Anonymous said...

Exactly what I was looking for. Thanks!

Anonymous said...

:Hover does not work on button

Andrew Gunn said...

I thought it did!? If you send me the CSS and HTML for the button, I'll have a look.

Anonymous said...

Seems to me that hover works on Firefox, but not in Internetexplorer.
I am looking for a way to make the cursor a hand as on a real link, but that doesnt work...