开发者

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜