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,如非必要請勿重複