C# Code in ASPX Page
ASPX:
<%@ Page %>
<HTML>
<Title>使用全站点计数器</Title>
<!--#Include file="GlobCount.inc"-->
<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
GlobalGraph(MyPanel);
}
</script>
<BODY bgColor="white">
<font face="楷体_GB2312"><strong>全站点计数器</strong></font>
<form runat="server">
<asp:Panel id="MyPanel" runat="server" width="50%" BorderColor="#C0FFC0" BorderStyle="Groove"></asp:Panel>
</form>
</FORM>
</BODY>
</HTML>
GlobCount.inc:
<script language=c# runat="server">
void GlobalGraph(Panel Container)
{
Image Img;
Label lbl;
string count ;
String graph;
lbl=new Label();
lbl.Text="该站点已被访问次数:";
Container.Controls.Add(lbl);
count =Application["Counter"].ToString();
for (int i=0;i<count.Length;i++)
{
Img=new Image(); //动态生成Image控件
graph=count.Substring(i,1);
Img.ImageUrl=graph + ".gif";
Container.Controls.Add(Img); //加载到控件容器
}
}
</script>