I have a user control in mvc 2.0, where i have a table of anchor tags created by using Html.ActionLink(title,action,controller). Now out of these several anchor tags, one will have a particular class applied to it, what is the best method to do this ?
Darin:) Using this, I will have to apply the conditional logic in the view itself, i have to apply class to only one of the several anchor tags based on the action. In this case I will have to check 20 times if this is the action, if I have 20 anchor tags. I want something like inherited class out of ActionLink which will check the action and apply the class based on it to only one of the anchor tags.
There is an overload which allows you to pass html attributes such as a CSS class:
UPDATE:
You could also write a custom ActionLink helper which would do the job:
and then in your view: