Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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.

like image 276
Jerad Rose Avatar asked May 11 '11 03:05

Jerad Rose


1 Answers

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. The dropdown

like image 189
turtlepick Avatar answered Nov 15 '22 07:11

turtlepick