views:

62

answers:

3

Is it possible (using HTML5 Shiv, for example) to implement HTML5 on a Webforms-based platform? Will ASP.NET Webforms allow the developer to semantically mark up a page using the new HTML5 elements?

+2  A: 

I'd say ASP.net MVC is more suited to this type of development but I dont see any overwhelming reasons why you couldn't produce webforms pages using HTML5 as it't for the most part an extension to HTML4.

Probably a lot more hand-coding pages than the RAD drag and drop webforms (unfortunately) encourages.

Chris M
Is it possible to implement the new form features using ASP.NET controllers though (as an example)?
Jayphen
Yes I use placeholder every day in webforms any "none" recognized attribute is just added to the page. Might be more difficult to add these through the codebehind but i know its possible. I.e. (<asp:TextBox ID="ref" runat="server" MaxLength="10" placeholder="Enter a Ref"></asp:TextBox>)
Chris M
+1  A: 

You can create your own custom controls that will render down to whatever html elements you want..

You can output to the page whatever HTML you want, you just have to control that output. So whereas the standard set of Asp.Net controls will output to normal HTML elements like

<label /> and <input /> etc.. You can do your own implementation quite easily.

Also there is nothing stopping you adding custom classes or html5 css attributes to the rendered HTML of Asp.Net controls, just bear in mind that the HTML5 isn't well supported with actual browser usage yet..

Markive
Also you can put runat='server' onto any HTML element and control a lot of it's attributes and add custom ones in your code at runtime, simple example would be visible='false' or myControl.visible = false in code.
Markive
Are you saying that you would have to manually re-write parts of the framework to allow it to output form input fields with the "placeholder" attribute, for example?I'm strictly talking about HTML5 here btw, not CSS3 (so classnames are irrelevant)
Jayphen
No so say you have a textbox with an id of 'myTextbox', all you do in your code is: myTextbox.Attributes.Add("placeholder", "My PlaceHolder Text"). Asp.Net does not care.. If you are doing something very customt that you want to re-use as a control you may want to look into control templating / custom controls.
Markive
A: 

I say yes you can but if you want to make complex change it doesn't have to be easy task. You have full control on markup placing in aspx and ascx files and on markup generated in your own custom controls. In code behind code you can use Attributes collection of controls to add HTML5 specific attributes. For build in web controls you can create your own ControlAdapters which will overwrite rendering of build in web controls.

Check this article for description of control adapters.

Ladislav Mrnka