开发者

How to disable VS compile warning "class or css class is not defined"

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 s开发者_StackOverflow社区p1.

Thanks!


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜