Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid "The class or CssClass value is not defined" Warnings in ASP.NET MVC ASCX Partial Views (UserControls)

I wondered how I can stop those annoying compiler warnings "The class or CssClass value is not defined" coming from my ASP.NET MVC partial views/ASCX user controls. The CSS is correctly defined, but the reference to the CSS file is obviously on the master page only. My partial views contain lots of CSS class references on div's etc. and so I get massive amounts of warnings which I shouldn't see.

How can I solve this?

Thank you !

like image 753
Alex Avatar asked Jul 28 '09 16:07

Alex


2 Answers

Include this in your partial view:

<% if (false) { %>
   <link rel="stylesheet" type="text/css" ...
<% } %>

This will make intellisense happy, and excludes the stylesheet when the page is rendered, so that it is not included twice.

like image 184
Robert Harvey Avatar answered Nov 16 '22 01:11

Robert Harvey


One way is to turn HTML Syntax Checking off (Tools->Options->Text editor->HTML->Show Errors->In CSS).

I use the Firefox Tidy plug in, which gives better advice, IMHO.

like image 24
Craig Stuntz Avatar answered Nov 16 '22 03:11

Craig Stuntz