为Ajax Action添加一个css类



如何为Ajax.ActionLink添加一个类?

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

但是这个方法不为这个ActionLink创建css类。我的类被添加到url:admintool/RemovePhoto/ffff.JPG吗?类= RemovePhoto

您可以使用(AjaxHelper, String, String, Object, AjaxOptions, Object)方法签名。

public static MvcHtmlString ActionLink(
    this AjaxHelper ajaxHelper,
    string linkText,
    string actionName,
    Object routeValues,
    AjaxOptions ajaxOptions,
    Object htmlAttributes
)
如您所见,最后一个参数是HTML属性的集合。

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

应该这样使用:

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

最新更新