我已經當前創建一個擴展方法創建的HtmlHelper擴展方法,但它仍然要求
using System.Web;
using System.Web.Mvc;
namespace Mobi.QualityControl.Site.Infrastructure
{
public static class HtmlHelpers
{
public static HtmlString ActionImage(this HtmlHelper htmlHelper, string action, object routeValues, string imagePath, string alt)
{
var url = new UrlHelper(htmlHelper.ViewContext.RequestContext);
// build the <img> tag
var imgBuilder = new TagBuilder("img");
imgBuilder.MergeAttribute("src", url.Content(imagePath));
imgBuilder.MergeAttribute("alt", alt);
string imgHtml = imgBuilder.ToString(TagRenderMode.SelfClosing);
// build the <a> tag
var anchorBuilder = new TagBuilder("a");
anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
anchorBuilder.InnerHtml = imgHtml; // include the <img> tag inside
string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
return new HtmlString(anchorHtml);
}
}
}
那麼我想在我的網頁與使用使用額外的第一個參數聲明在我的web.config中,它正在挑選方法,但它
@ HtmlHelpers.ActionImage(「帳戶/註冊」,「/images/home/gettingstarted.png」,「編輯」,「GettingStarted」)
它說它仍然需要5個參數不是4.
它可能是一個非常簡單的東西。任何幫助,將不勝感激。
乾杯我認爲這是簡單的事情 –