Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to

I have a single page(created before Master pages were available) that loaded dynamically one or another user control.Some child controls have css for quirk mode, but for new controls I want to use latest DocType
<!DOCTYPE html>
The solution is to set it dynamically in code-behind depending on current control to load(the code is copied from

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<asp:literal runat="server" id="DocType"></asp:literal>

<html xmlns="">
<head runat="server">
==============code behind=========
protected void Page_Load(object sender, EventArgs e)
string docType;
docType= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
docType= "<!DOCTYPE html>”

this.DocType.Text= docType;


Posted on Friday, September 23, 2011 9:38 PM ASP.NET , CSS/DHTML/JavaScript | Back to top

Comments on this post: Change DocType dynamically

# re: Change DocType dynamically
Requesting Gravatar...
My "master" page knows which control has been loaded(stored in PageID parameter), and I can hardcode the controls that required old docType
Left by Michael Freidgeim on Nov 26, 2011 8:52 AM

# re: Change DocType dynamically
Requesting Gravatar...
Left by nah on Nov 26, 2013 1:36 PM

Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: