0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

8 Comments

Yeah, I don't know why they used that Configuration Manager magic/trickery - maybe because they could! Thanks for the IE tip. I usually use Chrome and Firefox, but I'll give that a try.
Actually Chrome and Firefox can do that too. But IE makes it more simple. And every single user of ASP.NET C# or even the whole language is kinda confused. Hey do you use WebMatrix? If you did you must have noticed it automatically checks the HTML CSS JavaScript and all other standards. And tells you where there is an error. Give it a try too. Thats even better then IE Developer Tools.
Yes, I do use WebMatrix (at home; not at work); actually, I switch back-and-forth between VS2012 and WM at home. WM has some cool features, as you mention, but I find it easier to add Nuget packages, etc., via VS. As to "automatically checks" you're talking about the Report it runs, correct?
NuGet packages are available for WebMatrix too. However no! Reports contains a whole bunch of info about your website the time the code takes to execute, the things that might you missed while writing or combining code. But I am saying about that Errors tab under the page codes. The one with the Find! At the end of the WebMatrix. It tells you where what is required!
I mean it offers you to check the broken links too. Or the pages that take too much time to load!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.