ASP.Net中用C#实现站点计数器用户控件
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="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_c
相关文档:
我们今天来讲一下该体系结构中的XmlTextReader类,该类提供对Xml文件进行读取的功能,它可以验证文档是否格式良好,如果不是格式良好的Xml文档,该类在读取过程中将会抛出XmlException异常,可使用该类提供的一些方法对文档节点进行读取,筛选等操作以及得到节点的名称和值,请牢记:XmlTextReader是基于流模型的实现,打个 ......
C#代码与javaScript函数的相互调用
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中 ......
如何运用 Form 表单认证
ASP.NET 的安全认证,共有“Windows”“Form”“Passport”“None”四种验证模式。“Windows”与“None”没有起到保护的作用,不推荐使用;“Passport”我又没用过,唉……所以我只好讲讲“Form”认 ......
public static void SetEnterControl(System.Web.UI.Control Ctrl)
{
Page mPage = Ctrl.Page;
string mScript;
mScript = @"<script language=""jav ......
很多同学都读过这篇文章吧 ASP.NET MVC中你必须知道的13个扩展点,今天给大家介绍一个ASP.NET MVC的扩展库,主要就是针对这些扩展点进行。这个项目的核心是IOC容器,包括Ninject, StructureMap, Unity ,Windsor和Autofac。如果你和我一样喜欢使用IOC,这个库值得你关注,这些IOC我都用过了,现在比较喜欢使用Autofac。
AS ......