国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET2.0 WebRource,開發(fā)微調(diào)按鈕控件

2024-07-10 13:10:48
字體:
供稿:網(wǎng)友

現(xiàn)在。有許多開發(fā)人員已經(jīng)在使用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>目前我發(fā)現(xiàn)webresource.axd的參數(shù)跟現(xiàn)在版本有屬不同。在早期文章介紹屬性:
a 程序集名稱
r 資源文件名稱
t 程序集最后修改的時間
 


webresource.axd只是isapi中的一個映射。你也可以在使用ihttphandler。<add verb="get" path="webresource.axd"     type="system.web.handlers.assemblyresourceloader" /> webresource.axd是通過assemblyresourceloader類來自定義處理http請求,根據(jù)所query傳遞的程序來識別從哪個程序集中獲取哪個資源。

下面以微調(diào)控件為示例。

使用步驟:
添加要嵌入的資源(比如圖像)到項(xiàng)中
在資源管理器中,單擊文件,在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源碼當(dāng)中。你需要使用下面代碼來獲取圖像
    // 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.(獲取對服務(wù)器端資源的 url 引用)
我發(fā)現(xiàn)在早期版本當(dāng)中。它的使用方法是:this.page.getwebresourceurl

上面代碼是從指定的程序集中當(dāng)中獲取圖像名稱:obies.web.ui.webcontrols.numerictextbox_" + this.imageset.tostring() + "_btnup.gif,它返回的是一個服務(wù)器端資源的url引用地址。類似于:
webresource.axd?d=gwyjblnqkynoteplj34jxyospr2rh9lpyd8zrsl0&amp;t=632812333820000000

另外,ms提供一個header類。header類主要是對html頁面中的<head runat="server"></head>的操作。包括title等
呵呵。以后要修改一個頁面的標(biāo)題很很簡單了。
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
            string css = this.page.clientscript.getwebresourceurl (typeof(numerictextbox),
 "obies.web.ui.webcontrols.numerictextbox_" + this.imageset + ".css");
            // register the css
           // this.page.stylesheettheme = css;
            //this.page.header.linkedstylesheets.add (css); 
//早期版本的方法?只能用下面的代碼來解決了
            htmllink link = new htmllink();
            link.attributes.add("type", "text/css");
            link.attributes.add("rel", "stylesheet");
            link.attributes.add("href", css);
            this.page.header.controls.add(link);

        }      
下面是微調(diào)控件的截圖

使用方法:
<%@ register tagprefix="cc" namespace="obies.web.ui.webcontrols" assembly="obies.web.ui.webcontrols" %>

<cc:numerictextbox width="50" imageset="silver" length="2" runat="server" id="numerictextbox1"
maxvalue="10" minvalue="0"></cc:numerictextbox>
<cc:numerictextbox width="50" imageset="green" length="2" runat="server" id="numerictextbox2"
maxvalue="10" minvalue="0"></cc:numerictextbox>

來源地址:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
dnvs05/html/webresource.asp
由于原來的代碼有點(diǎn)問題,很多特性都是最新vs2005不支持的。所以進(jìn)行了修改。
源碼下載:http://www.cnblogs.com/files/cnzc/postwebformbetweenframes.zip

在寫這篇文章查了很多資料。也嘗試用心去寫。但總感覺寫的不是很好。網(wǎng)上也有相關(guān)的webresource的介紹。但發(fā)現(xiàn)很多都是目前最新版本不支持的。不知道是不是以前asp.net2.0早期版本。所以才進(jìn)行了簡單的修改。
以后在努力了。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 通道| 麻江县| 类乌齐县| 靖江市| 合水县| 宣城市| 临漳县| 棋牌| 武城县| 额尔古纳市| 静安区| 隆安县| 衡山县| 汉寿县| 孝昌县| 浮梁县| 达拉特旗| 宜黄县| 景谷| 璧山县| 浑源县| 康定县| 集安市| 吴川市| 紫云| 昌图县| 商都县| 平顶山市| 隆德县| 鹿泉市| 鸡泽县| 琼海市| 美姑县| 华安县| 长治市| 红原县| 龙门县| 临清市| 北票市| 辛集市| 浮山县|