zoukankan
html css js c++ java
使用ASP.NET 2.0提供的WebResource管理资源
ASP.NET 2.0提供的Web Resources管理模型,很好的解决了image、css、script等外部资源的管理问题
在自定义控件中加入(
放在最高级namespace外就行
。
)
[assembly: WebResource(
"
WebCtrl.cutecat.jpg
"
,
"
image/jpg
"
)]
[assembly: WebResource(
"
WebCtrl.cutecat.js
"
,
"application/x-javascript
"
)]
代码:
WebResource Demo
#region
WebResource Demo
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Text;
using
System.Web.UI;
using
System.Web.UI.WebControls;
[assembly: WebResource(
"
WebCtrl.cutecat.jpg
"
,
"
image/jpg
"
)]
namespace
WebCtrl
{
[DefaultProperty(
"
Text
"
)]
[ToolboxData(
"
<{0}:WebCustom runat=server></{0}:WebCustom>
"
)]
public
class
WebCustom : WebControl
{
private
string
text;
private
Image m_Image;
[Bindable(
true
)]
[Category(
"
Appearance
"
)]
[DefaultValue(
""
)]
public
string
Text
{
get
{
return
text; }
set
{ text
=
value; }
}
protected
override
void
CreateChildControls()
{
m_Image
=
new
Image();
this
.Controls.Add(m_Image);
}
protected
override
void
Render(HtmlTextWriter output)
{
m_Image.ImageUrl
=
this
.Page.GetWebResourceUrl(
typeof
(WebCustom),
"
WebCtrl.cutecat.jpg
"
);
this
.RenderChildren(output);
}
}
}
#endregion
查看全文
相关阅读:
记一次VS2010和VS2015自定义颜色的过程
Git使用笔记
VS winsock.h和ws2def.h大量重定义报错的问题
在ASP.NET MVC 3中使用日志记录组件Elmah和NLog
Entity Framework 6新特性:全局性地自定义Code First约定
在ASP.NET MVC 3 中自定义AuthorizeAttribute时需要注意的页面缓存问题
SSH开发记录
iOS开发知识要点
(收藏)在 iPhone/iPad 中随意修改数字键盘按钮
iPhone开发 – 数据持久化
原文地址:https://www.cnblogs.com/goldnet/p/1077895.html
最新文章
回忆去年用Java破解unity.exe的过程
JGroups TCP 发现机制解读
netty做Pipe一端快一端慢时防止内存溢出进行的操作
.net 里的CalendarExtender 日历显示中文
for in 在浏览器中的不同,已经对时间排序的不同
Asp.net 数据库缓存依赖(SQLServer 2005)
qq表情符的替换和页面显示
php下把文件中行数据转换为数组
Ubuntu下apache的多虚拟主机配置
Css 截取字符串
热门文章
js中的url编码
jQuery ajax传参巧用JSON
解决Visual Studio “无法导入以下密钥文件” 错误
JS 禁用退格键
Linux下编译tinyxml生成动态库
解决“在证书存储区中找不到清单签名证书”
获取url参数
数组删除指定项
数组与字符串相互转换
动态规划 归类总结
Copyright © 2011-2022 走看看