3

In VS 2008, when I compile, I get a large series of The class or CssClass value is not defined messages.

How do I get the error/warning code (something like "C0167") for that message, so I can disable it?

Answers that won't work:

  • The compiler gives you the warning number. No, it doesn't.
  • See the list of MSDN compiler errors (found at http://msdn.microsoft.com/en-us/library/5feh24w0%28VS.71%29.aspx). No, it's not there.
  • Look at the Output tab for "Build". No, warnings don't seem to be listed there.
  • Right click and select Show Error Help. No, this just brings up Markup Validation in Visual Web Developer, which doesn't give me the code I need.
  • Put a fake <%=If false Then %> block with a fake reference to the css include file on every page, to stop the error. Well, yes, I could do that, but that defeats the purpose of not just putting my reference directly on all my pages to begin with. I'm asking for how to suppress the message.
  • Turn off all html validation in Tools/Options and then the Text Editor / HTML / Validation "Show Errors" checkbox. Yes, that's what I might have to do, but it's a shame to turn off all html validation, much of which is very helpful, especially to junior developers.

I'm in a vb.net project, using sp1.

4
  • The Output Window "Debug" drop down is used when the application is running. Build errors and warnings are listed in the Output Window under "Build". Did you check the "Build" drop down, or did you mean "Build" and wrote "Debug"?
    – Dan Joseph
    Commented Jun 24, 2010 at 20:15
  • Ah, I meant Build. You are wise. Fixing my question now . . . Commented Jun 24, 2010 at 20:21
  • What about Tools->Options->CSS->CSS Specific-> Detect invalid values? Commented Jun 24, 2010 at 21:54
  • That doesn't fix it. I think that section deals with how VS deals with errors in CSS areas, not in referencing CSS. Commented Jun 25, 2010 at 0:21

1 Answer 1

1

After trying things for some time I have determined that these warning messages are generically tied to HTML validation, and do not have specific codes like Compiler Warnings. As such there is an all or nothing option to disable these warnings under Tools->Text Editor-> HTML-> Validation.

Old:

Here is something you might try. From ASP.NET:

<link href="/css/main2.css" rel="stylesheet" type="text/css"  runat="server" 
id="styleMain" visible="false" />

playing around with the root path in href seems to make a difference:

<link href='~/css/main2.css' rel='stylesheet' type='text/css' />

Well I had an interesting time changing the schema for the validation rules (found here):

C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\schemas\html

Using xhtml (1.0 transitional) validation I edited xhtml_trasitional.xsd and removed cellspacing as a valid attribute of table. When I restarted VS it flagged cellspacing as an invalid attribute. Maybe there is a solution in there. Although those errors say "Validiation (XHTML 1.0 TRANSITIONAL)" in front of them, as opposed to "class or css class is not defined" which may imply it is coming from somewhere else.

4
  • Thanks Jack. I'm not using an .ascx page or even web forms (I'm using MVC). See my 5th bullet in my question: I could put something on every page to make this not happen, but then, I could just put my css reference on each page. I'm looking for a way to suppress the message so I don't have to trick Visual Studio, on every single page, into not giving me the warning. Commented Jun 24, 2010 at 20:42
  • While I recognized you weren't making an ASCX, I thought it might be adaptable to your scenario. Commented Jun 24, 2010 at 21:00
  • right, I should have mentioned mvc; I just updated my tags. It certainly is a tricky situation. Commented Jun 24, 2010 at 21:03
  • I no longer believe it is possible to disable specific warnings generated from the html validation. Commented Jun 25, 2010 at 17:18

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.