Can built-in ASP.net 4.0 webform controls output HTML5? - webforms

We're looking to gear up and support HTML5.
I believe that the built-in web controls in asp.net 4.0 output XHTML.
From what I understand the built-in controls do not yet ouput HTML5, however is it possible from them to output HTML4?
I don't particulary want to output a mixmatch of HTML / XHTML as although I'm sure most browsers will just deal with it, it seems like an approach that will have bad surprises.
From what I understand, XHTML5 support isn't great in browsers (though I'm still researching that).
The idea being that the surrounding HTML can make use of HTML5 and the controls just use HTML4 for the moment until asp.net catches up?

HTML5 output is supported:
For HTML5 features to work properly in Web Forms or views, you need to replace <!DOCTYPE> and <html> with their HTML5 counterparts. In ASP.NET Web Forms, this code belongs in the master page. In ASP.NET MVC, this code belongs in the _Layoutpage.cshtml layout page.
Regardless of the file type, the markup is the same, as demonstrated here:
<!DOCTYPE html>
<html>
XHTML5 support is simple to add using a doctype, namespacing and some styles:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta charset="utf-8"/>
<meta name="description" content="XHTML example for styling HTML5 elements in Internet Explorer without Javascript using namespaces."/>
<meta name="author" content="Elco Klingen"/>
<meta name="copyright" content="Copyright (c) 2010 Elco Klingen"/>
<title>HTML5 elements in Internet Explorer without Javascript - XHTML Example</title>
<style>
.section, section, html5\:section {
display: block;
padding: 0 75px;
border: 5px solid #e6e6e6;
background: #cfc;
}
</style>
</head>
<body>
<html5:section>foo</html5:section>
<section>bar</section>
<!--...-->
</body>
</html>

Related

Respond.js not working locally - Support for media queries in IE8

I am writing a html page using bootstrap3 template and including the respond.js in that, but when I run it on IE8, it gives me error "Access is denied" in console.
I am using this to make IE8 support media queries. I have tried a lot of things as given on forums, but no luck. Does respond.js works locally or we need to run on a localhost/web server?
Respond.js link - https://github.com/scottjehl/Respond
HTML:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/main.css" rel="stylesheet" media="screen">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>Hello, world!</h1>
<div class="main-cont">
</div>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
CSS - main.css
.main-cont {background:#2d3a42; height:100px;}
Per the Respond.js Docs...
"Due to security restrictions, some browsers may not allow this script to work on file:// urls (because it uses xmlHttpRequest). Run it on a web server."
Specifically, "Respond.js re-requests the CSS files using Ajax and parses the text response," which is where IE's local security policy is blocking you. Another user elsewhere suggested changing the security settings in IE, but I can't confirm that solution since my copy of IE8 doesn't permit me to change those settings.
Oh, and to save you the trouble, I already tested and confirmed that using ajaxSetup() method in jQuery to set "isLocal" property to "true" won't overcome the local restriction in IE.
I just managed to make respond.js run on IE8 for media queries support , by running on localhost. If simply the html file opened, it does not help.

Issues forcing IE9 to render like IE8

I'm trying to render a webpage in Explorer as IE8, since IE9 is doing a great mess with CSS and not showing the #font-face.
I read the Microsoft Documentation here: http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx and other related topics like IE9 does not at all care about 'X-UA-Compatible' meta tag and Force IE9 to emulate IE8. Possible? and none resolved my issue, either I am very dumb (witch can be) or I can't find the problem.
The webpage is: karactermania.com/web2012/betty and I'm using the CMS Textpattern to build it.
I tried with:
<!-- Enable IE8 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<!-- Enable IE8 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE8" /> (as I found some examples written with and without the "=")
<!--[if IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE8" >
<![endif]--> (desperate attempt)
Complete HTML declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xmlns:fb="http://ogp.me/ns/fb#">
<head>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE8" />
If anyone can point where the error is and how can I fix it, will earn my eternal gratitude :)
Thanks
I had the same problem as you. My X-UA-Compatible header was ignored. I found the solution in this post
The x-ua-compatible header has to be in the head section, before all other elements except for the title element and other meta elements

Trying to use Gecko Engine with ABCPdf and classic ASP

i'm trying to create dynamic PDF's using ABCPdf and i'm having no success. I copied their sample code and tried it and i receive an error:
Unable to render HTML. No MSHTML document is available.
I'm trying to figure out how to use the Gecko engine to reder the page instead of IE and can't find how. Any help is greatly appreciated... thanks all!!!
damien
Please see https://stackoverflow.com/a/11504285/1411950. This example uses the 1 rectangle for html->pdf output on each page. The rectangle is filled with raw html / html from url. It also can use Gecko engine.
If you want to make dynamic pdf, you should use raw html for its content. Note, that it should be wrapped into something like
const String HtmlWrapper = #"<!DOCTYPE html>
<html>
<head profile='http://www.w3.org/2005/10/profile'><title></title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<style type='text/css'>
</style>
</head>
<body>
{0}
</body>
</html>";
where all css goes in script tags in the header or is referenced to

asp.net mvc 3 razor sections and portable areas

Is it possible to have a portable area feed into a ASP.Net MVC 3 razor section? I have a section in my for placing JS files, CSS, fiels, etc. I want to be able to target the head section from portable areas for any JS, CSS files the portable area needs. Is this possible?
Thanks
Tom
You can use master page concept just like _Layout.chtml to put portable sections. (It event works for header)
<!DOCTYPE html>
<html>
<head>
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet"
type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.4.4.min.js")"
type="text/javascript"> </script>
#{
//access your portable section here.
}
</head>
<body>
#RenderBody()
</body>
</html>

Firefox Addon HTML Validator showing Canvas not recognized

I'm using the HTML Validator Addon in Firefox 4 (great tool I might add).
However, I'm not sure the validation is working the way it should. I'm getting an error saying 'Canvas is not recognized'.
My doctype and html tags are set as follows:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
I believe this is supposed to be the HTML5 way for setting doctypes.
Is there something I'm missing?!
Try removing xmlns="http://www.w3.org/1999/xhtml" from the <html> element.

Resources