在对静态页面进行点击数统计时,
有的网友是采用先经过一动态页面(如:reader.aspx)进行计数后,再重定位到静态页的方法.

此方法并不好,其主要缺点是不重新生成静态页就无法得到正确计数值.

我们可以在静态页的浮动帧中运行aspx页面.
以<iframe width=50 height=20 frameborder=0 scrolling=no src=counter.aspx></iframe>
来更新和读取不断变化的点击数.

counter.aspx页的代码:

public void page_load(Object obj,EventArgs e)
{
  string id=Request.QueryString["Nid"];
  if(id!=null){
    if(!checkid(id)){
         Response.Write("<script>alert('非法参数!!');"+"</"+"script>");
         Response.End();
    }
    else{
       int nid=Convert.ToInt32(id);
       ..//连接数据库升级点击数.
       ..//显示当前点击数
    }
  }
  else
    Response.Write("无参数传递,错误!!");
}


//验证输入id是否为非法参数
public bool checkid(string str){
 try{
  int i=int.Parse(str); 
 }
 catch{
  return false;
 }
 return true;
}

相关文章:

  • 2021-11-01
  • 2022-12-23
  • 2022-02-13
  • 2022-02-07
  • 2021-12-10
  • 2022-02-18
  • 2021-07-06
  • 2021-10-17
猜你喜欢
  • 2021-11-24
  • 2021-12-10
  • 2021-10-19
  • 2022-01-10
  • 2021-04-28
相关资源
相似解决方案