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
查看全文
相关阅读:
ssh
datetime
网络-sdn(2)
django-drf
Vscode前段常用插件
Vscode离线安装插件
CSS 实现绘制各种三角形
flex布局
js实现全选和取消全选
购物车用Ajax向后台传参
原文地址:https://www.cnblogs.com/goldnet/p/1077895.html
最新文章
队列的封装(线性循环队列)
栈的封装
蓝桥杯——代表团出访——C++
蓝桥杯 ——无重复组合——C++
蓝桥杯 ——积木问题——C++
crontab计划任务
有关git的配置
Linux的目录结构
vamare下centos7.0 动态获取ip报错问题
nginx反向代理+负载均衡+https
热门文章
mysqlbinlog备份和mysqldump备份
优化mysql的内存
分析nginx日志常用的命令总结
mysql通过mysqldump实现备份,脚本编写
nginx 的日志切割
ip
curl
k8s证书
es-es入门
selenium自动化
Copyright © 2011-2022 走看看