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
相关文档:
趁周末想折腾一下嵌入ASP.NET的WinForm程序
需要用到WebBrowser控件的HTML源码读写
就把以前的一些代码片断移值到C#下
顺便发个帖子备忘,呵呵
思路其实很简单,直接通过document.documentElement.outerHTML
或者使用IPersistStreamInit接口直接对流进行处理
前者我就不废话了,后者实现方法如下
&nbs ......
转载自:http://www.cnblogs.com/jdmei520/archive/2009/06/17/1505053.html
Webservice技术的出现将各种开发技术和语言完全的融合了,下面就这种融合在C#和delphi之间的交互做一次全面的体现
1.使用C#创建一个Webservice服务。
使用vs2005的模板创建C#的webservice非常容易。原文件如下:
[WebService(Namespace  ......
• 不要使用不必要的Session,和ASP中一样,在不必要的时候不要使用Session
• 不使用不必要的Server Control
• 不使用不必要的ViewState
• 不要用Excepti ......
Asp.Net 备份和恢复SQL SERVER 数据库
我们通常备份数据库时,需要登录数据库服务器去备份和恢复,这样很不方便,其实SQL SERVER自带的命令可能让我们很简单地实现远程通过Asp.Net备份和恢复数据库。
BACKUP DATABASE '被备份的数据库名' TO DISK = '备份文件路径';
ALTER DATABASE '被恢复的数据库名' ......
在asp.net里怎么跟据用户权限来生成树形菜单
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
......