我是靠谱客的博主 拉长雪糕,最近开发中收集的这篇文章主要介绍mvc可以写html5吗,HTML5 in MVC,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

HTML5 in MVC

02/09/2012

2 分钟可看完

本文内容

HTML5 is a hot topic lately and developers are eagerly investigating ways to use HTML5. One of the more widely discussed capabilities are the built-in form type controls enforcing validation and allowing for placeholder values - new input types such as “color”, “date|datetime”, “email”, “phonenumber” are now supported in browsers such as Opera and Firefox.

Example:

HTML5 is not yet standardized and not supported in the more broadly utilized browsers … so how can we leverage these capabilities when supported … and yet provide a similar experience for users of non-html5 browsers?

It was this problem that motivated me to create the example project I’ll be covering today – and I threw in a few other useful examples to scenarios often requested by customers.

First I leveraged the nuget package mvchtml5templates which provides new EditorTemplates for the HTML5 types. If you haven’t discovered nuget yet – you are in for a treat. Install the latest version from nuget.org – and you can set Package Manager to check for updates automatically via VS2010 Tools|Options|Package Manager| Automatically "Check for Updates" checkbox.

The EditorTemplates will output with the native html5 types, then I used Modernizer in Javascript to check if the type is supported by the browser.

Example:

if (!Modernizr.inputtypes.email))…

Modernizer uses a combination of pre-defined browser capabilities and real-time client-side capability checks to determine this. If it is supported – then we get the benefit validation and native browser controls for the types. If not – then we leverage JQuery for validation, generating controls for the given type (eg date and color) and placeholder.

There are also a few of other scenarios I’ve covered in this example that I’ll describe in future blog posts such as:

Using a JQuery Dialog for the item editing with Ajax and the AntiForgeryToken.

Deleting a row from the grid using Ajax and without a full grid refresh.

Leveraging ViewModels.

Supporting IoC / Repository pattern.

Dev vs. Production setup for Jquery references

T4MVC

最后

以上就是拉长雪糕为你收集整理的mvc可以写html5吗,HTML5 in MVC的全部内容,希望文章能够帮你解决mvc可以写html5吗,HTML5 in MVC所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部