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
查看全文
相关阅读:
开源包管理系统和环境管理系统 Conda
浅谈 Python 的模块导入
用 pytest 测试 python 代码
关于特征筛选中的IV值
二 k-means聚类算法的手动实现
二 统计量及其抽样分布
PAT B1056组合数的和
PAT B1061判断题
'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
Hadoop搭建高可用的HA集群
原文地址:https://www.cnblogs.com/goldnet/p/1077895.html
最新文章
AS开发文档
DataTable筛选器
yyyy-mm-dd hh-mm--ss
WPF学习之绘图和动画--DarrenF
C#操作注册表--DarrenF
WPF之Binding深入探讨--Darren
C# 文件操作(全部) 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名
WPF MediaElement播放器2
Custom Media Player in WPF (Part 1)
WPF对于xml的简单操作(下下)插入节点并排序
热门文章
WPF对于xml的简单操作(下)绑定ListView
IOS 开发didFinishLaunchingWithOptions 设置启动View
Difference between WCF and Web API and WCF REST and Web Service[转]
一文让你读懂如何使用eclipse做Python开发
用python实现新年祝福微信的自动回复
Python 模块简介 -- functools
Python上下文管理器与with语句
SQL 的基本使用概念简介
Sqlite 基本概念及使用概述
一个命令行 Python 工具 -- Pythonpy
Copyright © 2011-2022 走看看