开发者

How to create a doctype with TagBuilder

开发者 https://www.devze.com 2023-04-09 19:56 出处:网络
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.

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

精彩评论

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