选择显示字体大小

asp.net2.0 webrource,开发微调按钮控件

现在。有许多开发人员已经在使用asp.net2.0的webresource的功能了。webresource允许我们嵌入资源到程序集中。包括图像,文本等。

在介绍webresource就不得不介绍一下webresource.axd,我们来看一下

script language="javascript"     src="webresource.axd?a=s&r=webuivalidation.js&t=631944362841472848"     type="text/javascript"></script>目前我发现webresource.axd的参数跟现在版本有属不同。在早期文章介绍属性:
a 程序集名称
r 资源文件名称
t 程序集最后修改的时间
 


webresource.axd只是isapi中的一个映射。你也可以在使用ihttphandler。<add verb="get" path="webresource.axd"     type="system.web.handlers.assemblyresourceloader" /> webresource.axd是通过assemblyresourceloader类来自定义处理http请求,根据所query传递的程序来识别从哪个程序集中获取哪个资源。

下面以微调控件为示例。

使用步骤:
添加要嵌入的资源(比如图像)到项中
在资源管理器中,单击文件,在property window(属性窗口)中build action选择embedded resource(嵌入资源)。
添加下列文件到你的assessbly.cs文件哪中
[assembly: webresource("obies.web.ui.webcontrols.numerictextbox.js", "application/x-javascript")]
[assembly: webresource("obies.web.ui.webcontrols.numerictextbox_silver_btnup.gif", "image/gif")]请注意webresourceattribute格式:
[assembly: webresourceattribute("mynamespaces.resources.myimage.gif", "image/gif")]
在control源码当中。你需要使用下面代码来获取图像
    // get webresource urls for the embedded gif images
            string btnupimgsrc = this.page.clientscript.getwebresourceurl(typeof(numerictextbox),
 "obies.web.ui.webcontrols.numerictextbox_" + this.imageset.tostring() + "_btnup.gif");getwebresourceurl method:gets a url reference to a server-side resource.(获取对服务器端资源的 url 引用)
我发现在早期版本当中。它的使用方法是:this.page.getwebresourceurl

上面代码是从指定的程序集中当中获取图像名称:obies.web.ui.webcontrols.numerictextbox_" + this.imageset.tostring() + "_btnup.gif,它返回的是一个服务器端资源的url引用地址。类似于:
webresource.axd?d=gwyjblnqkynoteplj34jxyospr2rh9lpyd8zrsl0&amp;t=632812333820000000

另外,ms提供一个header类。header类主要是对html页面中的<head runat="server"></head>的操作。包括title等
呵呵。以后要修改一个页面的标题很很简单了。
this.header.title = "this is the new page title.";
添加css样式(style attribute) style style = new style();
style.forecolor = system.drawing.color.navy;
style.backcolor = system.drawing.color.lightgray;

// add the style to the header for the body of the page
this.header.stylesheet.createstylerule(style, null, "body");

protected override void onprerender (eventargs e) {
            // get a webresource url for the core js script and register it
            this.page.clientscript.registerclientscriptresource(typeof(numerictextbox),
"obies.web.ui.webcontrols.numerictextbox.js");   
            // get a webresource url for the embedded css


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons