Click here to Skip to main content
15,915,603 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How do you change the BACK link:
HTML
@Html.ActionLink("Back to List", "Index") 
in my .cshtml into a button?
Posted
Updated 27-Sep-13 9:11am
v2
Comments
Jameel VM 27-Sep-13 12:01pm    
did you mean the style?
TryAndSucceed 27-Sep-13 12:05pm    
You need to apply a stylesheet.

1 solution

HTML

@Html.ActionLink("Back to List", "Index", new { @class = "button-link" }) 


CSS

C#
.button-link {
    padding: 10px 15px;
    background: #4479BA;
    color: #FFF;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    border: solid 1px #20538D;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
    -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
    -webkit-transition-duration: 0.2s;
    -moz-transition-duration: 0.2s;
    transition-duration: 0.2s;
    -webkit-user-select:none;
    -moz-user-select:none;
    -ms-user-select:none;
    user-select:none;
}
.button-link:hover {
    background: #356094;
    border: solid 1px #2A4E77;
    text-decoration: none;
}
.button-link:active {
    -webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
    -moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
    background: #2E5481;
    border: solid 1px #203E5F;
}


Out put

http://jsfiddle.net/jKYX6/[^]

For more info :

http://www.usabilitypost.com/2012/01/10/pressed-button-state-with-css3/[^]

I hope this will help to you.
 
Share this answer
 
v2
Comments
Member 10253325 28-Sep-13 5:27am    
I tried the @Html.ActionLink("Back to List", "Index", new { @class = "button-link" }) it still doesnt change the link to a button
Sampath Lokuge 28-Sep-13 5:33am    
Check the final out put of the control on chrome or fire bug dev tools and verify the CSS which I have mentioned above is applied properly.
Sampath Lokuge 28-Sep-13 5:59am    
Where's your ActionLink ????
Member 10253325 28-Sep-13 6:03am    
The whole solution didnt get pasted. In my mvc app its still picking up the old css not the updated one, not sure why
Sampath Lokuge 28-Sep-13 6:05am    
Do you have separate css file or use as inline style with same aspx page ?

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