html页面静态页面实现统计访问人数实例代码

详细请点击:http://www.verydemo.com/demo_c101_i57839.html



  1. 静态页面 staticHtml.html
  2. ">
  3. <strong>统计</strong>动态<strong><strong>页面</strong>访问</strong>量的几种方法
  4. 这是在层中显示
  5. 累加页面 act.aspx
  6. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="act.aspx.cs" Inherits="AddNumber" %>
  7. act.aspx.cs
  8. 代码
  9. public partial class AddNumber : System.Web.UI.Page
  10. {
  11.     private static int count = 1;
  12.     protected void Page_Load(object sender, EventArgs e)
  13.     {
  14.         count ;
  15.         Response.Write("var pv=document.getElementById(pv); pv.innerText=" count ";");
  16.     }
  17. }
  18. 静态页面 staticHtml.html
  19. ">
  20. <strong>统计</strong>动态<strong><strong>页面</strong>访问</strong>量的几种方法
  21. 这是利用图片进行显示
  22. 这是动态<strong>统计</strong>的数量
  23. 累加页面 Imageact.aspx
  24. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Imageact.aspx.cs" Inherits="ImageAddNumber" %>
  25. Imageact.aspx.cs 代码
  26. public partial class ImageAddNumber : System.Web.UI.Page
  27. {
  28.     private static int count = 1;
  29.     protected void Page_Load(object sender, EventArgs e)
  30.     {
  31.         count ;
  32.         string pv = count.ToString();
  33.         System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((pv.Length * 12.5)), 22);
  34.         Graphics g = Graphics.FromImage(image);
  35.         //图片背景色
  36.         g.Clear(Color.White);
  37.         Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
  38.         System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.White, Color.Red, (float)1.2f, true);
  39.         g.DrawString(pv,font, brush, 0, 0);
  40.         g.DrawRectangle(new Pen(Color.Gold), 0, 0, image.Width - 1, image.Height - 1);
  41.         System.IO.MemoryStream ms = new System.IO.MemoryStream();
  42.         image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
  43.         Response.ClearContent();
  44.         Response.ContentType = "image/Gif";
  45.         Response.BinaryWrite(ms.ToArray());
  46.     }
  47. }

你可能感兴趣的:(html页面静态页面实现统计访问人数实例代码)