Created
December 3, 2012 15:22
-
-
Save Jerph/4195688 to your computer and use it in GitHub Desktop.
ASP.NET Generic HTML5 Tag control for IE7 support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
public class Html5Tag : PlaceHolder | |
{ | |
public string TagName { get; set; } | |
public string FallbackTagName { get; set; } | |
public string CssClass { get; set; } | |
public Html5Tag() | |
{ | |
TagName = "div"; | |
FallbackTagName = "div"; | |
} | |
protected override void Render(HtmlTextWriter output) | |
{ | |
string classAndID = (string.IsNullOrWhiteSpace(CssClass) ? "" : " class=\"" + CssClass + "\"") | |
+ (string.IsNullOrEmpty(ClientID) ? "" : " id=\"" + ClientID + "\""); | |
output.WriteLine("<!--[if lte IE 8 ]><" + FallbackTagName + classAndID + "><![endif]-->"); | |
output.WriteLine("<!--[if (gt IE 8)|!(IE)]><!--><" + TagName + classAndID + "><!--<![endif]-->"); | |
base.Render(output); | |
output.WriteLine("<!--[if lte IE 8 ]></" + FallbackTagName + "><![endif]-->"); | |
output.WriteLine("<!--[if (gt IE 8)|!(IE)]><!--></" + TagName + "><!--<![endif]-->"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment