文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > C# DLL资源文件打包(图片、JS、CSS)[WebResource]
侵权投诉

C# DLL资源文件打包(图片、JS、CSS)[WebResource]

很好的C#下教您如何给dll打包

nerHtml = cs.GetWebResourceUrl(rstype, rsname);

// Register the client resource with the page.
cs.RegisterClientScriptResource(rstype, rsname);

}
</script>
<html >
<head>
<title>ClientScriptManager Example</title>
</head>
<body>
<form id="Form1" runat="server">
The web resource path is
<span id="ResourcePath" runat="server"/>.
<br /><br />
<input type="text" id="Message" />
<input type="button" onclick="DoClick()" value="ClientClick" />
</form>
</body>
</html>

为了方便直接看到效果,我把上面从DLL中读取JS的代码改成了从DLL中读取图片的代码,改动如下
1. 将ClientScriptResourceLabel命名空间改为FunkyTextBox
2. 将资源注册代码改成如下(注意资源路径):

[assembly: WebResource("FunkyTextBox.Resources.test.jpg", "image/jpeg")]
3. 为ASPX页面添加一个图片按钮并把读取的相应改成如下:

<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
// Define the resource name and type.
String rsname = "FunkyTextBox.Resources.test.jpg";
Type rstype = typeof(ClientScriptResourceLabel);

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Write out the web resource url.
imgpath.Src = cs.GetWebResourceUrl(rstype, rsname);
//ResourcePath.InnerHtml =

// Register the client resource with the page.
//cs.RegisterClientScriptResource(rstype, rsname);
}
</script>

<html xmlns="doc.guandang.net; >
<head runat="server">
<title>WebResources</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img runat="server" id="imgpath" alt=""/>

上面访问代码可以简化如下:
mgpath.Src = ClientScript.GetWebResourceUrl(typeof(FunkyTextBox), "FunkyTextBox.Resources.test.jpg");
由上面的代码我们可以看得出,ClientScriptResourceLabel类里面是空的,唯一有用的就是注册了一下资源,接下来我们把ClientScriptResourceLabel里面的资源注释掉,把资源注册到AssemblyInfo.cs中,也能够正确显示。这就让我纳闷了!type指向的是一个空的类也能够显示资源,但是我用this.GetType()或用typeof(_Default)通通都不行!!我猜想这个GetWebResourceUrl第一个参数只需要我们把他指引向正确的DLL空间就行了,然后就可以找到资源了!?还有我用Assembly.Load("FunkyTextBox").GetType()来指定Type也是不行的,感觉还是学得比较浅:)

上一页第2页

你可能喜欢

热门文档

相关文档

  • Dll控件里含图片,JS,CSS

    [assembly: System.Web.UI.WebResource("myStylesheet.css", "text/css")] ...1/2 相关文档推荐 C# DLL资源文件打包(图片... 2页 1下载券 JS调用DLL实例...

  • 如何把js文件编译成dll供页面调用

    如何把js文件编译成dll供页面调用_IT/计算机_专业....UI.WebResource("JSControl.JScript1.js", "..." OnClientClick="testAlert();" /> 9.效果图 ...

  • Asp NET使用HttpHandler打包多CSS或JS文件

    Asp NET使用HttpHandler打包多CSS或JS文件_计算机软件及应用_IT/计算机_专业... aspnet使用母版页时,js出... 暂无评价 2页 免费 C# DLL资源文件打包(图片...

  • 使用脚本+yuicompressor对js,css文件打包

    使用批处理和 yuicompressor 给 js 打包 项目中需要对 javascript 进行打包和压缩,我选用了 yuicompressor yuicompressor 可以压缩 JS 和 CSS 文件,去除文件中的无用...

  • 为JavaScript 文件嵌入本地化资源

    百度文库_文档分享平台 新闻网页贴吧知道音乐图片视频...(.dll 文件),其中包含要作为资源处理的 JavaScript ...WebResource 定义必须包含程序集的默认命名空间和 .js...

  • 如何能在.net2.0开发的控件中嵌入资源)

    webResource=程序集的默认命名空间+相对路径+文件名(...可以说控件可嵌入的资源 类型很多,图片,文本,视频...".dll"="application/x-msdownload" ".doc"="...

  • 青青源文件

    css" rel="stylesheet" href="http://blog.hjeng...> </script> <script src="/WebResource.axd?d=...sub 文件就是存放字幕本身了,注意是图片格式的,所以...

  • 青青源文件

    css" rel="stylesheet" href="http://blog.hjeng...> </script> <script src="/WebResource.axd?d=...sub 文件就是存放字幕本身了,注意是图片格式的,所以...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email