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
查看全文
相关阅读:
提问的智慧
Linux下Tomcat的安装配置
Advanced Puppet 系列的前言
一个purge参数引发的惨案——从线上hbase数据被删事故说起
从入门到精通Puppet的实践之路
Juno Puppet Opertaors Meetup小结
Openstack配置文件管理的变迁之路
如何成为一名Top DevOps Engineer
mod_wsgi的工作模式和配置
解决PuppetDB Failed to submit 'replace facts'问题
原文地址:https://www.cnblogs.com/goldnet/p/1077895.html
最新文章
挂羊头卖狗肉蓄意欺骗读者——谭浩强《C程序设计(第四版)》中所谓的“按照C99”(一)
C语言初学者代码中的常见错误与瑕疵(21)
C语言初学者代码中的常见错误与瑕疵(20)
MDK-ARM输出HEX文件重命名设置
曼侧斯特码
Github忽略keil工程生成的链接、编译等文件
GIT无法自动忽略YellowRV1.1.uvgui.Administrator文件的解决方法
状态机介绍
锂电池电压电量关系
Android BLE蓝牙开发-读写数据 获取UUID
热门文章
Service discovery
蓝牙发现服务UUID(service UUID)
蓝牙
FFmpeg av_seek_frame规律详解
H265(HEVC) nal 单元头介绍及rtp发送中的fu分组发送详解
Laravel 执行流程(一)之自动加载
如何设计一款优秀的短视频 SDK
Android WebRTC开发入门
云游戏真的来了,这次的搅局者是 Google,云游戏平台搭建
如何有效地报告 Bug
Copyright © 2011-2022 走看看