2

I'm feeling a bit lost with my question about HTML5 code generation, and despite having put some efforts into my research I don't really feel much wiser.

I use VS2010 for the creation of ASP.NET pages, and I do know that there is an (unofficial) "Web Standards Update" for VS2010 SP1. Using this update I can change the settings of the "Target Schema for Validation" in the ASPX editor window to HTML5. The new elements / tags and semantics are then available via Intellisense, and I can nicely code away manually using all the fancy new stuff.

What I don't understand is how to get something like the ASP.NET controls to generate HTML5 code (where it makes sense). Is this at all possible or am I completely going in the wrong direction here? I would have expected that I do not have to "hand code" HTML5 as long as I use the existing controls (which tend to generate a lot of JavaScript in the background when the page is delivered to the client's browser).

Thanks in advance for a clarifying answer

G.

1
  • You can't "generate semantic HTML5". The things that "generate semantic HTML5" are called programmers. If a machine can do that your fired. Commented Dec 16, 2011 at 13:44

2 Answers 2

2

Some controls generate slightly different dialects of HTML based on the particular User-Agent. However, not all of them know about HTML 5 yet, and there's no specific property to enable HTML 5 generation, just as there isn't a property to enable other dialects of HTML.

If you want to generate HTML 5, you can do one of three things:

  1. Create a new control that overrides the existing one, and either use it directly or replace the original with it everywhere in your app with tag mapping
  2. Create a control adapter and modify the control's output as it's generated
  3. Create a custom control
Sign up to request clarification or add additional context in comments.

1 Comment

I'd add a fourth option: use an existing custom control. I made an open-source suite of HTML5 inputs and controls for people who don't want to migrate their whole project to MVC. This gives you the same syntax you're used to in WebForms, Intellisense for the properties, and postback.
1

The controls you are referring in ASP.NET are what is commonly known as "webforms". They are basically server side controls that generates the javascript code needed to postback the data to the server, mantain the state of the controls between postbacks, and stuff like that. As you said, those controls generate too much code and a excessive number of roundtrips to the server, so it is not very recommended to use webforms.

HTML5 is mainly client side, so it has very little to do with the webforms server controls. It's a different approach than the old ASP.NET webforms. Because of this, ASP.NET is including on its newer versions the MVC framework, the razor engine, JQuery and another javascriprt libraries. MVC includes some helper classes and templates that helps you generating the client code, and many other features to support HTML5 enabled webs. So, I would recommend to start reading about it. Anyway, now that jquery is fully integrated in Visual Studio, javascript coding is not so difficult.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.