国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net中用C#實現(xiàn)站點計數(shù)器用戶控件

2024-07-10 13:00:14
字體:
供稿:網(wǎng)友
----------------
資源:同級目錄下的存放當(dāng)前計數(shù)的count.txt文件
子目錄pic下的0到9的數(shù)字圖片0.gif ~ 9.gif
--------------------------------
asax文件:
<%@ control language="c#" autoeventwireup="false" codebehind="counter.ascx.cs" inherits="jianweb.counter" targetschema="http://schemas.microsoft.com/intellisense/ie5"%>
<link href="css.css" rel="stylesheet">
<font face="宋體">
<table id="table_counter" cellspacing="0" cellpadding="0" width="750" align="center" border="0"
runat="server">
<tr>
<td style="height: 23px" align="center" valign=middle><img height="1" alt="" src=http://www.163design.net/n/c/"pic/rightblueback.gif" width="700"></td>
</tr>
<tr>
<td align=center valign=middle></td>
</tr>
</table>
</font>
-------------------
.cs文件:
namespace jianweb
{
using system;
using system.data;
using system.drawing;
using system.web;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;

/// <summary>
/// counter 的摘要說明。
/// </summary>
public class counter : system.web.ui.usercontrol
{
protected system.web.ui.htmlcontrols.htmltable table_counter;

private void page_load(object sender, system.eventargs e)
{
// 在此處放置用戶代碼以初始化頁面
string filepath=system.web.httpcontext.current.server.mappath("hits.txt");
system.io.streamreader srreadline = new system.io.streamreader(
system.io.file.openread(filepath),
system.text.encoding.ascii);//encoding.default是讀中文
srreadline.basestream.seek(0, system.io.seekorigin.begin);//
string countstr="";
if (srreadline.peek() > -1)
{
countstr+=srreadline.readline();
}
int count=int.parse(countstr)+1;
countstr=count.tostring();
srreadline.close();
table_counter.rows[1].cells[0].innerhtml="<font color=/"#009900/">";
for (int i=0;i<countstr.length;i++)
{
table_counter.rows[1].cells[0].innerhtml=table_counter.rows[1].cells[0].innerhtml+"<img src=http://www.163design.net/"pic//"+countstr.substring(i,1)+".gif/">";
}
table_counter.rows[1].cells[0].innerhtml+="</font>";

// write the string to a file.
system.io.streamwriter file = new system.io.streamwriter(filepath);
file.writeline(countstr,false);

file.close();
srreadline.close();
}

#region web 窗體設(shè)計器生成的代碼
override protected void oninit(eventargs e)
{
//
// codegen: 該調(diào)用是 asp.net web 窗體設(shè)計器所必需的。
//
initializecomponent();
base.oninit(e);
}

/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void initializecomponent()
{
this.load += new system.eventhandler(this.page_load);

}
#endregion
}
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 濮阳县| 永兴县| 翼城县| 横山县| 方山县| 资阳市| 夹江县| 营口市| 通山县| 江津市| 潮安县| 潼关县| 鲁甸县| 仲巴县| 景洪市| 东海县| 凤翔县| 舞阳县| 鄯善县| 肥东县| 泸定县| 新源县| 武邑县| 汤原县| 澄迈县| 汉源县| 九寨沟县| 鲜城| 同仁县| 靖远县| 微博| 民权县| 莆田市| 鄂尔多斯市| 平舆县| 正安县| 京山县| 蒙山县| 册亨县| 富阳市| 绥中县|