Question

I use the w3.org validators for HTML and CSS (and jsfiddle for jQuery), but I find that in the case of HTML and CSS, I have to modify my markup and style rules by removing Razor code (the "@" stuff) such as:

.ui-widget-header .ui-icon { background-image: url('/@ConfigurationManager.AppSettings["ThisApp"]/Content/Images/ui-icons_228ef1_256x240.png'); }

(yes, that really is the name of the image)

...and:

@Html.LabelFor(m => m.BeginTime)

Also, since with ASP.NET you can have the "pieces parts" of your html distributed (some in the layout file, some in the current file, etc.) the HTML validator at http://validator.w3.org/ thinks your HTML is missing things like a head section, etc.

Of course, one could gather all that html together - I guess by running the page and selecting "View Source" to get the generated HTML - but when the page is not running, and THAT's why you're trying to validate it to track down the problem, that's not an option.

So: Is there a validator for CSS and, more importantly, HTML, that "understands" ASP.NET / Razor?

Was it helpful?

Solution

Then for images why don't you simply use:

'../Content/Images/ui-icons_228ef1_256x240.png'

That would be more like it!
Well I don't think there is an option to send the raw code to the validators!
Have you tried using IE Developer Tools? Press F12 and they will come up. From there you can get the Validator for the ASP.NET Razor. I use it myself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top