When using ASPX templates, how can I change the value of DocType?

HelenaG Grulichova asked on March 19, 2012 10:43

When using ASPX templates, how can I change the value of DocType?

Correct Answer

HelenaG Grulichova answered on March 19, 2012 10:43

As seen in the Developer’s Guide documentation Creating ASPX Master Pages, you can use <%=DocType%> as your doctype declaration in your master pages. The default value is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">. If you would like to change this, for instance to declare HTML5 (<!DOCTYPE html>), you can do so in the code behind of your master page. In the OnPreRender method of your master page codebehind (e.g., Root.master.cs), add a line defining this.Doctype:
 

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
 
        ltlTags.Text = HeaderTags;
 
        // Declare the doctype as html5
        this.DocType = "<!DOCTYPE html>";  
    }

-ag-
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.