易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

C#连接MySql数据库方法 宇兰

1、用MySQLDriverCS连接MySQL数据库
先下载和安装MySQLDriverCS,地址:http://sourceforge.net/projects/mysqldrivercs/在安装文件夹下面找到MySQLDriver.dll,然后将MySQLDriver.dll添加引用到项目中注:我下载的是版本是 MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe using System;using System.Collectio ......

C#实现XML系列化和反系列化的总结

常用的系列化定义(using System.Xml.Serialization;)
[XmlAttribute("name")]        // 定义<Tag name="…"></Tag>
[XmlElement("label")]        // 定义<label>…</label>
[XmlIgnoreAttrib ......

ASP.NET页面间传值方法

一、目前在ASP.NET中页面传值共有这么几种方式:
1、表单提交,
   <form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
   </form>
   ....
   for ......

asp.net页面刷新后的滚动条位置不变

只需在asp.net页面的Page指令中设置MaintainScrollPositionOnPostback="true"就可以轻松实现。
MaintainScrollPositionOnPostback属性的默认值为false。
另外asp.net的page对象还有一个SmartNavigator属性,这个属性我也试过。。好像对于css有影响。页面布局有点变化。。不是很好使 ......

Asp.net在权限驱动下动态生成菜单的两种方法

这些内容比较简单,但是比较容易忘记。特写下来帮助记忆:(这里用的是TreeView和XmlDataSource绑定的例子)
第一种:对属性的值直接进行绑定。
     首先 :拉一个TreeView到页面上,ID命名为"TrvLeft"。然后在后台进行绑定,
代码如下:
     XmlDataSource XmlDb = new Xml ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号