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

這篇文章給大家分享的是有關(guān)ASP.NET2.0 WebRource,開發(fā)微調(diào)按鈕控件的示例的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、成都網(wǎng)站制作、會澤網(wǎng)絡(luò)推廣、小程序開發(fā)、會澤網(wǎng)絡(luò)營銷、會澤企業(yè)策劃、會澤品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供會澤建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:bm7419.com

現(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)控件為示例。

使用步驟:
添加要嵌入的資源(比如圖像)到項中
在資源管理器中,單擊文件,在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&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

感謝各位的閱讀!關(guān)于“ASP.NET2.0 WebRource,開發(fā)微調(diào)按鈕控件的示例”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

網(wǎng)頁題目:ASP.NET2.0WebRource,開發(fā)微調(diào)按鈕控件的示例
網(wǎng)頁地址:http://bm7419.com/article36/jccppg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、網(wǎng)站策劃、商城網(wǎng)站軟件開發(fā)、企業(yè)建站、標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化