How to create a doctype with TagBuilder
The !
in the doctype ta开发者_如何学Pythong I cannot create. Is there a way to put the ! in a doctype tag using tagbuilder.
Since the Doctype is not an HTML tag, you can't use TagBuilder.
Although, you can return a normal MvcHtmlString.
public static class CustomHelpers
{
public static MvcHtmlString DocType(this HtmlHelper helper)
{
var docType = @"<!DOCTYPE ...>";
return MvcHtmlString.Create(docType);
}
}
And then use it like that:
@Html.DocType()
精彩评论