Alan
Alan

Reputation: 211

.NET - Is it possible to use ASP.NET without MVC using HTML 5?

Is it possible to use ASP.NET without MVC using HTML 5? A link would be great.

Upvotes: 6

Views: 2068

Answers (5)

unmounted
unmounted

Reputation: 34408

Here is a good link describing what is possible and advisable now in forms: http://diveintohtml5.ep.io/forms.html , a lot of it is simple, backwards-compatible, and improves user experience (see especially placeholders, search inputs, email address input fields, url input types). There is no reason not to use these now, and they help a lot on mobile devices.

I think in asp.net you would have to use custom controls for some of it (ie, a text field hack that was designed by the WHATWG specifically to trick IE is not a core part of existing control objects.) An easier work-around might look like this:

<asp:TextBox id="textbox1" runat="server" />

This yields html:

<input name="textbox1" type="text" id="textbox1" />

But your customer wants type="email" so you are in full Steve Jobs compliance mode. Simple work-around might be to add this javascript: document.getElementById("textbox1").type = "email". You would do the same ...etc_etc).type = "search" if you have a text box for search input and you want the benefits of html5 for users on devices that have usability enhancements for them.

See again here for more discussion. Also, apart from forms you should be able to use canvas, web storage, etc., via javascript.

Upvotes: 0

Jan Aagaard
Jan Aagaard

Reputation: 11204

If I had to choose between yes and no to this answer, I would have to say no.

All the built in controls in ASP.NET Web Forms do not generate HTML 5 code. They do generate HTML 4 compliant code, but it is not pretty by todays standards, especially because a lot of the controls use tables to render their layout. It is possible to change the html code for all the controls using CSS Friendly Control Adapters (http://www.asp.net/cssadapters/). In fact, I would advise you to check out that website, since it illustrates some of the bad markup of ASP.NET.

You can of course make an ASP.NET website without using the built in controls, but then I would advise to use MVC instead.

Correction: Sure it is possible to use ASP.NET to generate HTML 5, since HTML 5 is generally backwards compatible. But I wouldn't recommend the platform if you intent to create a state of the art HTML 5 web application for smartphones.

Upvotes: 0

Andrew Lewis
Andrew Lewis

Reputation: 5254

Of course it is. You will probably have to avoid the default set of controls, but there is absolutely nothing that prevents you from having strict HTML5 valid code. (Whatever that means).

Upvotes: 1

Mikael Svenson
Mikael Svenson

Reputation: 39695

There's not built-in controls in ASP.Net which uses html5 yet. But you can download a html5 schema which will work with VS2008 and VS2010 so you get intellisense on html5 compliant html.

http://blogs.msdn.com/b/webdevtools/archive/2009/11/18/html-5-intellisense-and-validation-schema-for-visual-studio-2008-and-visual-web-developer.aspx

Read the comments for using it with VS2010.

Upvotes: 5

ChrisLively
ChrisLively

Reputation: 88092

The platform has no bearing on whether you can use HTML 5 or not.

For example, if you have an asp.net web forms project, you can certainly make your .aspx files be HTML 5 compliant ... or not. Your choice.

To be clear, MVC, web forms, or whatever else has no bearing either. Those are, to simplify quite a bit, just processing technologies. You could deliver pure javascript and let that build your page client side if you wanted with any of them.

By the same token, php, java, ruby, etc can all be used to write html 5 compliant sites. If you were really ambitious you could even do it in pascal or c... or, if truly masochistic, ColdFusion ;)

Upvotes: 7

Related Questions