I am working with ASP.net MVC3, how I can add a CSS class to an @Html.Action(). I have done the following, but it isn't working:
@Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id, @class="test" })
Are you sure you don't want an ActionLink? Action() can't have any Html attributes applied to it since it renders your action and returns a string representation of it. Also, you are mixing route values and HTML attributes in your code. I think below is what you are looking for. It will render a link to an action:
@Html.ActionLink("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id }, new { @class="test" })
If Html.Action is what you intended (i.e. you want to physically render the action to a string) and you want to apply a CSS class to the parent container of the rendered view then you could do something similar to below:
<div class="test">@Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id })</div>
@Html.Actionrenders a child action not a hyperlink. You need to use@Html.ActionLinkto generate a hyperlink