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
查看全文
相关阅读:
JSON的基本认识
Linux基础 7-10 Bash编程练习4--for循环
Linux基础7-9 Bash编程--for循环语句
linux基础 7-3-条件判断语句案例
Linux基础 7-8 sed命令使用练习
Linux基础 7-7 set命令的使用
Linux基础 7-6 Bash脚本编程练习3
Linux基础7-5 Bash脚本编程--算术运算
Linux基础7-4 Bash脚本编程练习2
Linux基础 7-3 Bash脚本编程--条件判断
原文地址:https://www.cnblogs.com/goldnet/p/1077895.html
最新文章
win10键盘不能用必须重启一次才可以
第一次在博客园写文章
SQL基础语言(学习于微信公众号:SQL数据库开发)
VBA-字典与用户界面设计+ACCESS系统开发
VBA-触"类"旁通-类模块
VBA-触类旁通:图形、图片、与表单控件
VBA-使用ADO操作外部数据
VBA-VBA中的用户信息交互
VBA-使用ActiveX控件
VBA- 使用数组
热门文章
VBA-使用DIR函数多文件合并
VBA-自定义函数和带参数的过程
数组去重的几种方法
JavaScript的数组的基本方法
ES6 的Set与Map 对象
jQuery实现轮播图(css的样式利用了less实现)
解决行内元素间隙问题
canvas 实现火焰的简单方式
canvas 实现简单的粒子运动效果
用点击事件的方式 实现二级下拉菜单(用javaScript与jquery,vue)
Copyright © 2011-2022 走看看