@Ajax.ActionLink("ActionLink", "Index", "Home", "https", "www", "title", new { id = 1, type = 1 }, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "detailsID", InsertionMode = InsertionMode.Replace }, new{ id = "testid"})
MVC.Ajax.ActionLink()只能显示文本内容在前端页面,不过很多时候 我们都使用图片作为超链接
public static IHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes = null) { var builder = new TagBuilder("img"); builder.MergeAttribute("src", imageUrl); builder.MergeAttribute("alt", altText); builder.MergeAttributes(new RouteValueDictionary(htmlAttributes)); var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions).ToHtmlString(); return MvcHtmlString.Create(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing))); }
@Ajax.ImageActionLink(Url.Content("~/Content/Images/favorite.gif"),"收藏", "AddFavorite",null, new AjaxOptions { UpdateTargetId = "addfavorite" })
时间: 2024-10-14 18:34:54