gpt4 book ai didi

ajax - ASP.NET MVC Ajax.ActionLink 与图像

转载 作者:行者123 更新时间:2023-12-03 05:22:30 28 4
gpt4 key购买 nike

有没有办法让图像充当ajax操作链接?我只能使用文本让它工作。感谢您的帮助!

最佳答案

来自 Stephen Walthe,来自他的 Contact manger project

 public static class ImageActionLinkHelper
{

public static string ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions)
{
var builder = new TagBuilder("img");
builder.MergeAttribute("src", imageUrl);
builder.MergeAttribute("alt", altText);
var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions);
return link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing));
}

}

您现在可以输入您的 aspx 文件:

<%= Ajax.ImageActionLink("../../Content/Delete.png", "Delete", "Delete", new { id = item.Id }, new AjaxOptions { Confirm = "Delete contact?", HttpMethod = "Delete", UpdateTargetId = "divContactList" })%> 

关于ajax - ASP.NET MVC Ajax.ActionLink 与图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/341649/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com