Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
Can we set box shadow and other HOVER AND FOCUS STATES properties to a link button in asp.net?

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<link rel="Stylesheet" type="text/css" media="screen" href="css/linkstyles.css" />
<form runat="server">

<asp:LinkButton ID="LinkButton3" runat="server" BorderStyle="Groove" BorderWidth="3px" Font-Bold="True" Font-Underline="False"
                    OnClick="LinkButton3_Click"
                    Style="font-size: small; left: 734px; color: #ffffff;
                    font-family: Tahoma; position: absolute; top: 150px; background-color: #3579DC; height: 20px; width: 107px;"
                    OnClientClick ="return confirm('Are you sure you want to remove admin?');" >Remove Admin</asp:LinkButton>
</form>
</asp:Content>


my css page

.Content1 LinkButton2{
width:100px; /*same as the height*/
height:100px; /*same as the width*/
background-color:#ff0000;
border:1px solid #ff0000; /*same colour as the background*/
color:#fff;
font-size:1.6em;
/*set the border-radius at half the size of the width and height*/
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
/*give the button a small drop shadow*/
-webkit-box-shadow: 0 0 10px rgba(0,0,0, .75);
-moz-box-shadow: 0 0 10px rgba(0,0,0, .75);
box-shadow: 2px 2px 15px rgba(0,0,0, .75);
}
/***NOW STYLE THE BUTTON'S HOVER STATE***/
.Content1 LinkButton2:hover{
background:#c20b0b;
border:1px solid #c20b0b;
/*reduce the size of the shadow to give a pushed effect*/
-webkit-box-shadow: 0px 0px 5px rgba(0,0,0, .75);
-moz-box-shadow: 0px 0px 5px rgba(0,0,0, .75);
box-shadow: 0px 0px 5px rgba(0,0,0, .75);
}
Posted
Comments
Nandakishore G N 30-Jul-13 8:15am    
you cannot write LinkButton control in css. Because css supports only tag not the control.
Instead of .Content1 LinkButton2 replace it with
.lnkbtn2 and call the css class in linkbutton.
Roopa 10064853 30-Jul-13 8:41am    
Thank u it works well

1 solution

In css page

C#
.btn1
{
    color: #ffffff;
    background-color: #006697;

}
.btn1:hover
{

    border-bottom-style:groove;
    background:#3A6629;
    border:1px solid #3A6629;
/*reduce the size of the shadow to give a pushed effect*/
    -webkit-box-shadow: 0px 0px 5px rgba(0,0,0, .75);
    -moz-box-shadow: 0px 0px 5px rgba(0,0,0, .75);
    box-shadow: 0px 0px 5px rgba(0,0,0, .75);
}


In ASPX page

XML
<asp:LinkButton ID="LinkButton2" CssClass="btn1" runat="server" Font-Bold="True" BorderStyle="Groove" BorderWidth="3px" Font-Underline="False"
                   OnClick="LinkButton2_Click1"
                   Style="font-size: small; left: 449px;
                   font-family: Tahoma; position: absolute; top: 150px; height: 20px; width: 107px;"
                   OnClientClick ="return confirm('Are you sure you want to add admin?');" >Add Admin</asp:LinkButton>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900