简体   繁体   English

如何让 Visual Studio 的设计器在 ASP.NET Web 用户控件中正确呈现 CSS?

[英]How to get Visual Studio's designer to render CSS correctly in an ASP.NET Web User Control?

When developing a web user control, I'm styling everything with CSS.在开发 web 用户控件时,我使用 CSS 设计所有内容。 Whenever I look at the control in the designer, none of the CSS is rendered, or course, because I'm not looking at it in the context of the page where my link element is declared to my CSS file.每当我在设计器中查看控件时,都没有呈现 CSS,当然,因为我没有在我的链接元素声明到我的 CSS 文件的页面上下文中查看它。 Plus, Visual Studio will include a warning:此外,Visual Studio 将包含一个警告:

The class or CssClass value is not defined.未定义 class 或 CssClass 值。

for every class attribute I use.对于我使用的每个 class 属性。

I can get the designer to render the CSS if I include a link element in the control itself, but then I have duplicate link elements scattered throughout my pages.如果我在控件本身中包含一个链接元素,我可以让设计人员呈现 CSS,但是我的页面中散布着重复的链接元素。

Is there any way to get the designer to play nice with my CSS in a web control without injecting duplicate link elements everywhere?有什么方法可以让设计师在 web 控件中与我的 CSS 配合得很好,而不会到处注入重复的链接元素?

Sadly at the moment, I think that's the best you're going to get as seen here .可悲的是,我认为这是你在这里看到的最好的。

The only good news I can see is this Connect Issue which is "Closed - Postponed", so they may well be thinking about it.我能看到的唯一好消息是“已关闭 - 推迟”的Connect 问题,所以他们很可能正在考虑它。

The issue you've got is that you can make a control display very differently depending on the CSS rules applied with the styles - so one style sheet or a combination of parent tags could make (for example) labels appear above their form elements, and another beside them - which would you want to display when you are viewing the User control out of the page context?您遇到的问题是,您可以根据与 styles 一起应用的 CSS 规则使控件显示非常不同 - 因此一个样式表或父标记的组合可以使(例如)标签出现在其表单元素上方,并且旁边的另一个 - 当您在页面上下文之外查看用户控件时,您希望显示哪个?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM