我使用 MVC3 Razor 并有一个链接
<a href="@Url.Action("Edit", "Obj", new { id = RSAuth.UserId })" class="gray-butt right">Edit</a>
我已经写了 HtmlHelper
public static MvcHtmlString MyHelper(this HtmlHelper helper, string name, string href, string @class = null)
{
var builder = new TagBuilder("a");
builder.MergeAttribute("href", href);
builder.AddCssClass(@class);
builder.InnerHtml = name;
return new MvcHtmlString(builder.ToString());
}
这个链接不好
@Html.MyHelper("Edit","@Url.Action('Edit', 'Obj', new { id = RSAuth.UserId })", "gray-butt right")