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中页面传值共有这么几种方式:
1、表单提交,
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
for ......
只需在asp.net页面的Page指令中设置MaintainScrollPositionOnPostback="true"就可以轻松实现。
MaintainScrollPositionOnPostback属性的默认值为false。
另外asp.net的page对象还有一个SmartNavigator属性,这个属性我也试过。。好像对于css有影响。页面布局有点变化。。不是很好使 ......
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1 ......
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public ......