濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > ASP.NET顯示漸變圖片實(shí)現(xiàn)方法

ASP.NET顯示漸變圖片實(shí)現(xiàn)方法

熱門標(biāo)簽:寧德防封版電銷卡 上海市三維地圖標(biāo)注 西寧電銷外呼系統(tǒng)公司 海東防封電銷卡 南昌自動(dòng)外呼系統(tǒng)線路 云南外呼系統(tǒng)代理 安陸市地圖標(biāo)注app 辦公用地圖標(biāo)注網(wǎng)點(diǎn)怎么操作 聊城智能電銷機(jī)器人電話

先給大家來個(gè)最終效果:

實(shí)現(xiàn)效果,首先準(zhǔn)備一張圖片,高度為25pixel,寬度為1至3pixel漸變的圖片。可以這里下載。

還要準(zhǔn)備數(shù)據(jù):

Dictionaryint, int> Datas 
 { 
 get 
 { 
 Dictionaryint, int> d = new Dictionaryint, int>(); 
 d.Add(1, 35); 
 d.Add(2, 45); 
 d.Add(3, 20); 
 return d; 
 } 
 } 

ok,數(shù)據(jù)準(zhǔn)備完了,在aspx里放三個(gè)Label控件,當(dāng)然你可以顯示在其它控件或是標(biāo)簽中,有一點(diǎn)要注意的是Width="300",它是漸變圖片在100%的寬度:

asp:Label ID="Label1" runat="server" style="margin: 3px;" Text="" Width="300" BorderWidth="1">/asp:Label>br /> 
 asp:Label ID="Label2" runat="server" style="margin: 3px;" Text="" Width="300" BorderWidth="1">/asp:Label>br /> 
 asp:Label ID="Label3" runat="server" style="margin: 3px;" Text="" Width="300" BorderWidth="1">/asp:Label>br /> 

把數(shù)據(jù)顯示于Label上:

protected void Page_Load(object sender, EventArgs e) 
 { 
 Data_Binding(); 
 } 
 
 private void Data_Binding() 
 { 
 int totals = 100; 
 foreach (KeyValuePairint, int> kvp in Datas) 
 { 
 double rate = kvp.Value / (double)totals; 
 
 double width = rate * 300; 
 switch (kvp.Key) 
 { 
 case 1: 
  this.Label1.Text = GradientImage(width, rate); 
  break; 
 case 2: 
  this.Label2.Text = GradientImage(width, rate); 
  break; 
 case 3: 
  this.Label3.Text = GradientImage(width, rate); 
  break; 
 } 
 } 
 } 
 
 private string GradientImage(double width, double rate) 
 { 
 return "IMG height='21' src='images/bar.gif' width='" + width + "' align='absMiddle'> " + rate.ToString("p"); 
 } 

以上就是ASP.NET實(shí)現(xiàn)漸變圖片的方法,希望對(duì)大家的學(xué)習(xí)有所幫助。

您可能感興趣的文章:
  • ASP.NET實(shí)現(xiàn)圖片以二進(jìn)制的形式存入數(shù)據(jù)庫
  • asp.net 將一個(gè)圖片以二進(jìn)制值的形式存入Xml文件中的實(shí)例代碼
  • asp.net(c#)實(shí)現(xiàn)從sqlserver存取二進(jìn)制圖片的代碼
  • asp.net基于Web Service實(shí)現(xiàn)遠(yuǎn)程上傳圖片的方法
  • ASP.NET實(shí)現(xiàn)上傳圖片并生成縮略圖的方法
  • ASP.NET圖片處理三類經(jīng)典問題
  • ASP.NET中圖片顯示方法實(shí)例
  • asp.net實(shí)現(xiàn)圖片以二進(jìn)制流輸出的兩種方法

標(biāo)簽:南寧 青海 崇左 衢州 洛陽 贛州 汕尾

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET顯示漸變圖片實(shí)現(xiàn)方法》,本文關(guān)鍵詞  ASP.NET,顯示,漸變,圖片,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET顯示漸變圖片實(shí)現(xiàn)方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP.NET顯示漸變圖片實(shí)現(xiàn)方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    敦煌市| 五莲县| 子长县| 闵行区| 视频| 赣榆县| 太白县| 仲巴县| 罗甸县| 咸丰县| 宿迁市| 民丰县| 海丰县| 巴东县| 静宁县| 盘山县| 盐亭县| 资阳市| 偃师市| 伊吾县| 星子县| 乌拉特后旗| 库尔勒市| 长岛县| 建始县| 长宁县| 金寨县| 晋宁县| 开阳县| 台北市| 日喀则市| 安顺市| 天气| 靖边县| 彰化市| 新民市| 镇宁| 宜章县| 武清区| 扶余县| 鸡西市|