Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How could I dynamically change the css of a actionLink control on CSHTML page.
Suppose, I am getting a "type" parameter on the CSHTML page and on this "type" parameter basis I want to change the css of "ActionLink" on a CSHTML page.
Please suggest.

Thank you,

Regards,
Ashish
Posted

Actionlink is actually an anchor link

using JQuery you can do it.

$("input['type=myaction']").attr('class','newclass');

or

$("input['type=myaction']").css('background-color:','red');

or

$("input['type=myaction']").attr('style','background-color:red');
 
Share this answer
 
v3
Comments
Aashish vermaa 15-Sep-14 7:02am    
If I want to change the CSS of a particular "ActionLink".
@Html.ActionLink("Home", "", "", null, (ViewBag.type == "your type") ? new { @class = "typeclass" } : new { @class = "otherclass" })
 
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