开发者

Getting VS2010, and specifically a Razor view, to recognize custom "data-" attributes as valid

开发者 https://www.devze.com 2023-03-04 19:55 出处:网络
I know that HTML5 supports custom data-* attributes, and I know that VS2010 SP1 is supposed to have HTML5 support included.

I know that HTML5 supports custom data-* attributes, and I know that VS2010 SP1 is supposed to have HTML5 support included.

However, when I installed VS2010 SP1, I'm still getting validation errors on elements with data-* attributes.

For example, this:

<a开发者_如何学JAVA id="Clicky" data-for="@Model.Id">Clicky</a>

Yields the following warning in VS2010:

Validation (XHTML 1.0 Transitional): Attribute 'data-for' is not a valid attribute of element 'a'.

While I understand that these are just warnings and can safely be ignored, I'm trying to keep my site as standards compliant as possible, and if my warnings list is spammed with these warnings, I won't be able to see the valid warnings through all the noise.

Am I doing something wrong, or must I live with seeing these warnings?

Thanks in advance.


There is a little dropdown that you need to change to use HTML5 or others (XHTML 5, XHTML 1.1, etc.)

Click View --> Toolbars --> HTML Source Editing.

There will be a dropdown. Then choose HTML5.

Getting VS2010, and specifically a Razor view, to recognize custom "data-" attributes as valid


There is also a "Web Standards Update" extension available in the Visual Studio Extension Manager that updates some of the CSS/HTML5 intellisense features.

http://visualstudiogallery.msdn.microsoft.com/a15c3ce9-f58f-42b7-8668-53f6cdc2cd83?SRC=VSIDE

0

精彩评论

暂无评论...
验证码 换一张
取 消