温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net简单防刷新图片计数器源码
当前文件:
ImgCounts/count.aspx.cs,打开代码结构图
ImgCounts/count.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
11
public partial class _Default : System.Web.UI.Page 12
{ 13
protected void Page_Load(object sender, EventArgs e) 14
{ 15
//该源码下载与http://www.51aspx.com 16
17
//记数器 18
int c = (int)Application["count"]; 19
int dc = (int)Application["day_count"]; 20
string count = c.ToString();//转换为字符串 21
string day_count = dc.ToString(); 22
//根据字符串每位的值调用图片 23
for (int i = 0; i < count.Length;++i ) 24
{ 25
int n = count.Length; 26
Image img=new Image(); 27
28
img.ImageUrl="~\\count\\"+count[i]+".gif"; 29
ph1.Controls.Add(img); 30
} 31
for (int i = 0; i < day_count.Length;++i ) 32
{ 33
int n = day_count.Length; 34
Image img = new Image(); 35
img.ImageUrl="~\\count\\"+day_count[i]+".gif"; 36
ph2.Controls.Add(img); 37
} 38
} 39
} 40





}
}