Mouse over effect

Posted by Joggee | ASP.NET Tips | Wednesday 4 June 2008 7:46 am

This is so simple and can found thousand places but I tried to make it more easier who doesnt know the different between <asp:linked button> or anchor.

Copy below code in your ASPX page.
 

 <table width=”50%” border=”1″ cellspacing=”0″ cellpadding=”0″>

<tr>
<td align=”center” class=”topmenulink”>
<a href=”<%=ResolveURL(”~/Default.aspx”) %> class=”topmenulink”>Home</a></td>
<td align=”center” class=”topmenulink”>
<a href=”http://blog.joggee.com/?page_id=11″ class=”topmenulink”>About Us</a></td>
<td align=”center” class=”topmenulink”>
<a href=”http://blog.joggee.com” class=”topmenulink”>Blog</a></td>
<td align=”center” class=”topmenulink”>
<a href=”http://www.joggee.com” class=”topmenulink”>Contact Us</a></td>
</tr>
</table>
create a CSS (Style sheet)

 copy below code in your CSS

.topmenulink

{
font-family: tahoma;
font-size: 13px;
font-weight: normal;
color:Blue;
text-decoration: none;
}
.topmenulink:hover
{
font-family: tahoma;
font-size: 13px;
font-weight: normal;
color: Blue;
text-decoration: none;
background-color: Khaki;
}

Note: you can change color scheme as per your site theme.

YOU CAN DOWNLOAD SAMPLE PROJECT HERE

I have used above ResolveURL Method,Just to give hint if you are using MASTER Page, then its recommendable to use ResolveURL to avoid any Warning or Problem.

If you want to how the hyperlink on the complete Button instead of TEXT then bring anchor link tag outside <TD> tag

<table width=”50%” border=”1″ cellspacing=”0″ cellpadding=”0″>

<tr>
<a href=”<%=ResolveURL(”~/Default.aspx”) %> class=”topmenulink”>Home

<td align=”center” class=”topmenulink”>

</td></a>

</tr>
</table>

Enjoy

Joggee

3 Comments »

  1. Comment by Seb — September 23, 2008 @ 11:06 pm

    It’s ugly, really ugly way to make a buton with rollover effect. You should read this blog : http://css-tricks.com/

    Cheers,

    S

  2. Comment by Vladlen — November 6, 2008 @ 5:25 am

    Thanks for the post. Poznovatelno.

  3. Comment by Payal — February 20, 2009 @ 12:36 pm

    Thanks for keeping it here, i needed it…
    :-)

RSS feed for comments on this post. TrackBack URI

Leave a comment