问题描述
我在ViewUserControl中有一个< table/>
,我已为标签赋予了 class ="tblRaised" 属性/值.Visual Studio保持基础 tblRaised 并告诉我-未定义类或CssClass.
I have a <table/>
in a ViewUserControl that I have given the tag a class="tblRaised" attribute/value. Visual Studio keeps underlying tblRaised and telling me - The class or CssClass is not defined.
为什么智能感知引擎试图在此处验证我的CSS类名称?还有其他人遇到吗?这是一个错误吗?Intellisense怎么会甚至知道我的css文件在ViewUserControl中的位置?
Why is the intellisense engine trying to validate my CSS class names here? Anyone else run into this? Is this a bug? How would intellisense even know where my css file was in a ViewUserControl?
推荐答案
由于样式通常包含在视图或母版页中,因此VS在ViewUserControl中找不到它们.如果将以下内容添加到ViewUserControl,则可以解决此问题(并获得智能感知),而无需两次包含CSS.
Because the styles are usually included in your view or master page, VS can't find them in your ViewUserControl. If you add something like the following to your ViewUserControl you can get around the issue (and get intellisense) without including the CSS twice.
<% if (false) { %>
<link rel="stylesheet" type="text/css" ...
<% } %>
这将获得智能感知,因为它可以找到样式表,但是使用if(false)实际上阻止了它在运行时被包含.
This will get the intellisense since it can find the stylesheet, but the use of if (false) actually prevents it from being included at runtime.
这篇关于ASP.NET MVC-ViewUserControl中的CSS类-未定义类或CssClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!