您好我想在MVC中使用HtmlHelper。但它不被認可。所以我嘗試使用System.Web.WebPages.Html添加。但是,在我的代碼中添加此代碼後,AnonymousObjectToHtmlAttributes無法識別。它是否被取消或其他?在MVC中找不到HtmlHelper類
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages.Html;
namespace TestFrame
{
internal class IframeBuilder
{
internal static HtmlString Iframe(object htmlAttributes)
{
IDictionary<string, object> parsedHtmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
TestFrame.IframeId = GetId(parsedHtmlAttributes);
string parsedIframe = CreateIframeTag(parsedHtmlAttributes);
parsedIframe += ReceiveMessageScript();
parsedIframe += SetIframeIdScript();
return new HtmlString(parsedIframe);
}
}
您是否添加了必要的參考資料? – Proxy
system.web.mvc你的意思是? – santro
MSDN says [HtmlHelper is in System.Web.Mvc](https://msdn.microsoft.com/en-us/library/system.web.mvc.htmlhelper.anonymousobjecttohtmlattributes(v = vs.118).aspx),而不是'System.Web.WebPages.Html'。 – Filburt