人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細頁面

Asp.Net中的記數(shù)器[初級]

Asp.Net中的記數(shù)器[初級]

更新時間:2022-08-08 文章作者:未知 信息來源:網(wǎng)絡 閱讀次數(shù):

global.asa
----------------------------------------------------------------------
<script language="c#" runat="server">
void Session_OnStart(){
Application.Lock();
Application["whoson"]=Convert.ToInt32(Application["whoson"])+1;
Application.UnLock();
}
void Session_OnEnd(){
Application.Lock();
Application["whoson"]=Convert.ToInt32(Application["whoson"])-1;
Application.UnLock();
}
public void Application_OnStart(){
Application.Lock();
Application["whoson"]=0;
Application.UnLock();
}
</script>
-------------------------------------------------------------------------

count_txt.asp

-------------------------------------------------------------------------

<%@ Page language="C#"%>
<%@ Import Namespace="System.IO"%>

<Script language="C#" runat="server">
public void Page_Load(Object src,EventArgs e)
{
//以下為讀取文件,當前目錄必須有count.txt這個文件否則會出錯
StreamReader sr=File.OpenText(Server.MapPath(".")+"\\count.txt");
Application.Lock();
Application["count"]=sr.ReadLine();
Application["count"]=Convert.ToInt32(Application["count"])+1;
Application.UnLock();
sr.Close();

//建立文件
StreamWriter rw=File.CreateText(Server.MapPath(".")+"\\count.txt");
Application.Lock();
rw.WriteLine(Application["count"]);
Application.UnLock();
rw.Flush(); //寫入
rw.Close();

count_1.Text="您是本站第"+Application["count"].ToString()+"位訪問者";
}
</Script>
<html>
<head>
</head>
<body>
<hr>
<asp:Label ID="count_1" runat="server"/>
</body>
</html>

global.asax文件與文本記數(shù)器的一樣,在此省略;
在images目錄中需要有0-9.gif十張圖片,同樣當前目錄需要有count.txt這個文件,否則會出錯
count_pic.aspx
-----------------------------------------------------------------------------------
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System.IO"%>
<script Language="C#" runat="server">
public void Page_Load(Object src,EventArgs e)
{
//以下為讀取文件
StreamReader sr=File.OpenText(Server.MapPath(".")+"\\count.txt");
Application.Lock();
Application["count"]=sr.ReadLine();
Application["count"]=Convert.ToInt32(Application["count"])+1;
Application.UnLock();
sr.Close();

//建立文件
StreamWriter rw=File.CreateText(Server.MapPath(".")+"\\count.txt");
Application.Lock();
rw.WriteLine(Application["count"]);
Application.UnLock();
rw.Flush(); //寫入
rw.Close();
}
public string G(int counter)
{
string myimage="";
string S=counter.ToString();
//strreplace=replace(strreplace,chr[92]);
for(int i=0;i<=S.Length-1;i++)
{
myimage =myimage+"<img src=./images/"+S.Substring(i,1)+".gif>";
}
return myimage;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>圖形記數(shù)器</title>
</head>
<body>
<%=G(Convert.ToInt32((Application["count"])))%>
</body>
</html>


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 新河县| 阳谷县| 平湖市| 资兴市| 陇西县| 郁南县| 犍为县| 大埔区| 红河县| 信宜市| 大宁县| 玉溪市| 石嘴山市| 文昌市| 拜泉县| 沧源| 南宁市| 山阳县| 淮滨县| 庆城县| 台东市| 通许县| 威宁| 武宁县| 仁寿县| 龙胜| 凌海市| 海南省| 兖州市| 呈贡县| 昭苏县| 特克斯县| 南溪县| 石城县| 泗阳县| 鹤壁市| 黄骅市| 洛隆县| 南溪县| 鄂伦春自治旗| 桐城市|