帶用戶端指令碼的圖片控制項,可利用後台代碼修改圖片顯示(C#代碼)

來源:互聯網
上載者:User

 

 1    public class SwapImg:System.Web.UI.HtmlControls.HtmlImage
 2    {
 3        public string imgurl;
 4        public string swapurl;
 5        public string clickurl;
 6        private int height;
 7        private int wight;
 8        private string tourl;
 9        private string id;
10        public SwapImg(string imgurl,string swapurl,string clickurl,int height,int wight,string tourl,string id)
11        {
12            this.imgurl=imgurl;
13            this.swapurl=swapurl;
14            this.clickurl=clickurl;
15            this.height=height;
16            this.wight=wight;
17            this.tourl=tourl;
18            this.id=id;
19        }
20        protected override void Render(HtmlTextWriter writer)
21        {
22            string write="<A href=\""+this.tourl+"\"><IMG onmousedown=\"FP_swapImg(1,0,/**//*id*/'"+this.id+"',/**//*url*/'"+this.clickurl+"')\" id=\""+this.id+"\"";
23            write=write+" onmouseover=\"FP_swapImg(1,0,/**//*id*/'"+this.id+"',/**//*url*/'"+this.swapurl+"')\" onmouseout=\"FP_swapImg(0,0,/**//*id*/'"+this.id+"',/**//*url*/'"+this.imgurl+"')\"";
24            write=write+" src=\""+this.imgurl+"\" border=0></A>";
25            writer.Write(write);
26        }
27    }

欄位解釋:

imgurl:普通狀態片url

swapurl:滑鼠移至上方的圖片url

clickurl:滑鼠點擊的圖片url

height:圖片高度

weight:圖片寬度

tourl:圖片連結

id:用戶端代碼id,如非必要請勿重複

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.