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

发布于 2024-07-19 00:48:55 字数 329 浏览 2 评论 0原文

在开发 Web 用户控件时,我使用 CSS 设计所有内容。 每当我查看设计器中的控件时,都不会呈现任何 CSS,当然,因为我不是在向 CSS 文件声明链接元素的页面上下文中查看它。 另外,Visual Studio 将包含一个警告:

未定义类或 CssClass 值。

对于我使用的每个类属性。

如果我在控件本身中包含链接元素,我可以让设计器呈现 CSS,但随后我的页面中散布着重复的链接元素。

有没有什么方法可以让设计者在 Web 控件中很好地使用我的 CSS,而无需在各处注入重复的链接元素?

When developing a web user control, I'm styling everything with 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. Plus, Visual Studio will include a warning:

The class or CssClass value is not defined.

for every class attribute I use.

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.

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太傻旳人生 2024-07-26 00:48:55

可悲的是,目前,我认为这是您能得到的最好的结果 见此处

我能看到的唯一好消息是这个 Connect Issue是“关闭 - 推迟”,所以他们很可能正在考虑这个问题。

您遇到的问题是,您可以根据样式所应用的 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.

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文