Add css class for Ajax Action link

How can I 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 does not create a css class for this ActionLink. My class is added to the URL: AdminTools / RemovePhoto / ffff.JPG? Class = RemovePhoto

+6
source share
2 answers

For this you can use the method signature (AjaxHelper, String, String, Object, AjaxOptions, Object) .

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

As you can see, the last parameter is a set of HTML attributes.

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

+8
source

The following should be used:

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

Source: https://habr.com/ru/post/896998/


All Articles