如何使用户控件了解一下ASP.NET CSS类 [英] How to make user controls know about css classes in ASP.NET

查看:107
本文介绍了如何使用户控件了解一下ASP.NET CSS类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于有在asp.net用户控件没有页眉部分,用户控件无法了解样式表文件的方式。所以CSS类的用户控件不被视觉工作室的认可并产生警告。我怎样才能让一个用户控件知道,这将涉及到一个CSS类,所以如果是警告我关于一个不存在的CSS类,这意味着该类真的不存在吗?

Since there are no header sections for user controls in asp.net, user controls have no way of knowing about stylesheet files. So css classes in the user controls are not recognized by visual studio and produces warnings. How can I make a user control know that it will relate to a css class, so if it is warning me about a non-existing css class, it means that the class really do not exist?

编辑:?或者我应该去一个不同的设计就像暴露CSS类像GridView控件的HeaderStyle-CssClass属性的属性。

Or should I go for a different design like exposing css classes as properties like "HeaderStyle-CssClass" of GridView?

推荐答案

下面是我所做的:

<link rel="Stylesheet" type="text/css" href="Stylesheet.css" id="style" runat="server" visible="false" />

这傻瓜的Visual Studio为您添加一个样式表的页面,但它不会呈现的思想。

It fools Visual Studio into thinking you've added a stylesheet to the page but it doesn't get rendered.


下面是一个更简洁的方式与多个引用做到这一点;

Here's an even more concise way to do this with multiple references;

<% if (false) { %>
    <link rel="Stylesheet" type="text/css" href="Stylesheet.css" />
    <script type="text/javascript" src="js/jquery-1.2.6.js" />
<% } %>

作为<一看到href=\"http://haacked.com/archive/2008/11/21/combining-jquery-form-validation-and-ajax-submission-with-asp.net.aspx\">this博客文章从菲尔哈克。

这篇关于如何使用户控件了解一下ASP.NET CSS类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆