【发布时间】:2013-03-02 12:49:00
【问题描述】:
我有一个旧的 webform 项目,现在已设置为 .net 4.0。我添加了 System.Web.MVC ref 4.0 但 TabBuilder 仍未显示为已知类型?
编辑:我也尝试添加 System.Web.WebPages 2.0 但这并不能解决问题。
【问题讨论】:
标签: asp.net asp.net-mvc reference webforms
我有一个旧的 webform 项目,现在已设置为 .net 4.0。我添加了 System.Web.MVC ref 4.0 但 TabBuilder 仍未显示为已知类型?
编辑:我也尝试添加 System.Web.WebPages 2.0 但这并不能解决问题。
【问题讨论】:
标签: asp.net asp.net-mvc reference webforms
请测试这段代码,看看this也许你忘了使用
using System.Web.Mvc;
using System.Web.Routing;
namespace MvcApplication1.Helpers
{
public static class ImageHelper
{
public static string Image(this HtmlHelper helper, string id, string url, string alternateText)
{
return Image(helper, id, url, alternateText, null);
}
public static string Image(this HtmlHelper helper, string id, string url, string alternateText, object htmlAttributes)
{
// Create tag builder
var builder = new TagBuilder("img");
// Create valid id
builder.GenerateId(id);
// Add attributes
builder.MergeAttribute("src", url);
builder.MergeAttribute("alt", alternateText);
builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
// Render tag
return builder.ToString(TagRenderMode.SelfClosing);
}
}
}
【讨论】: