Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a hyperlink inside a button in asp.net

I have a button on my asp.net page that (upon mouseover) needs to act like a hyperlink (the hand cursor). I cannot use a linkbutton because I need the GUI of a regular asp:button.

Is there a way to create the hyperlink cursor on mouseover?

Thanks

like image 950
DNR Avatar asked Aug 25 '11 21:08

DNR


3 Answers

Using css you can say:

.anchor {cursor: pointer; cursor: hand;}

and then in your aspx:

<asp:Button CssClass="anchor" ... >
like image 155
Mrchief Avatar answered Oct 20 '22 18:10

Mrchief


Use the following for the hand cursor on button mouse over:

<asp:Button ID="Button1" runat="server" Text="Click Me" CssClass="ButtonClass" />

The in a style sheet or inline in the page itself define the class:

.ButtonClass { cursor: pointer; cursor: hand; }

Use both (pointer and hand) for cross browser compatibility.

like image 42
Amulya Khare Avatar answered Oct 20 '22 17:10

Amulya Khare


Add this into your button's markup...

style="cursor: pointer; cursor: hand;"

so...

<asp:Button id="test" text="test" runat="server" style="cursor: pointer; cursor: hand;" />
like image 45
NoAlias Avatar answered Oct 20 '22 17:10

NoAlias