高分救教:类库中CSS文件(内嵌)如果涉及到图片(内嵌资源)的怎么引用

wyb716 2009-05-15 03:26:40
我有一个类库中,包括JS文件,CSS文件和图片,都是内嵌在类库中的资源。现CSS文件中有些背景要用类库中的图片资源作为背景,如何引用?我在网上查过用WebResource(""),试过不成功。
我是这样的格式写的:
background-image: '<%= WebResource(ClassLibrary1.btn_bg.gif)%>';
结果不成功。
...全文
159 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
CloneCenter 2009-05-16
  • 打赏
  • 举报
回复
我想楼主你可能需要单独做一个 aspx 页面,用于提取资源中的图片。页面传递不同的参数值,提取不同的图片,返回给调用者。

aspx 文件中,如何提取资源,参看周公的代码。
wyb716 2009-05-15
  • 打赏
  • 举报
回复
可能我表达不清楚吧,我说的不是在调用类库里面引用的问题。现在是类库里面有CSS,里面有属性要用到图片路径 ,而这个图片也是类库里的内嵌资源,怎么解决?再比如我类库里有一个普通的HTM页面,我要把样式文件给加进去,同样涉及到一个取样式文件路径的问题。
周公 2009-05-15
  • 打赏
  • 举报
回复
下面的代码示例演示如何查询 WebResource 属性的值。

此代码示例摘自一个为 WebResourceAttribute 类提供的更大的示例。

<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS.Controls" %>
<%@ Import Namespace="System.Reflection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{

// Get the assembly metatdata.
Type clsType = typeof(MyCustomControl);
Assembly a = clsType.Assembly;

// Iterate through the attributes for the assembly.
foreach (Attribute attr in Attribute.GetCustomAttributes(a))
{
//Check for WebResource attributes.
if (attr.GetType() == typeof(WebResourceAttribute))
{
WebResourceAttribute wra = (WebResourceAttribute)attr;
Response.Write("Resource in the assembly: " + wra.WebResource.ToString() +
" with ContentType = " + wra.ContentType.ToString() +
" and PerformsSubstitution = " + wra.PerformSubstitution.ToString() + "</br>");
}
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>WebResourceAttribute Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<AspNetSamples:MyCustomControl id="MyCustomControl1" runat="server">
</AspNetSamples:MyCustomControl>
</div>
</form>
</body>
</html>

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧