Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a css class for Ajax Action link

How I can add a class for Ajax.ActionLink?

@Ajax.ActionLink("Remove this photo","RemovePhoto","Admin",new{Id=Model.filename, @class="ActionClass"},new AjaxOptions{OnSuccess = "RemoveSuccess"})

but this method don't create css class for this ActionLink. My class is added to the url: AdminTools/RemovePhoto/ffff.JPG?class=RemovePhoto

like image 566
SirRoland Avatar asked Sep 09 '11 15:09

SirRoland


1 Answers

You can use the (AjaxHelper, String, String, Object, AjaxOptions, Object) method signature for this.

public static MvcHtmlString ActionLink(
    this AjaxHelper ajaxHelper,
    string linkText,
    string actionName,
    Object routeValues,
    AjaxOptions ajaxOptions,
    Object htmlAttributes
)

As you can see, the final parameter is a collection of HTML attributes.

Source: http://msdn.microsoft.com/en-us/library/dd470546.aspx

like image 89
Jamie Dixon Avatar answered Jan 03 '23 22:01

Jamie Dixon