静态网页计数和评论的解决

        静态网页如果做到动态的评论呢和计数呢,答案:javascript的document.write()
比如计数你可以嵌入<script language="javascript" src="hit.aspx"></script>
代码如下:
hit.aspx.cs
==
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class fabu_hit : System.Web.UI.Page
{
    public string Hit = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        int Id =int.Parse(Request.QueryString["id"]);
        string Source = System.Configuration.ConfigurationManager.AppSettings["Source"];
        SqlConnection Conn = new SqlConnection(Source);
        string Sql = "update information set hit = hit +1 where id ="+Id;
        SqlCommand Mycommand = new SqlCommand(Sql, Conn);
        Mycommand.Connection.Open();
        Mycommand.ExecuteNonQuery();

        string Sql2 = "select hit from information where id=" + Id;
        SqlCommand Comm = new SqlCommand(Sql2, Conn);
        Hit = Comm.ExecuteScalar().ToString();
       
    }
}
hit.aspx
==
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hit.aspx.cs" Inherits="fabu_hit" %>
document.write(<%=Hit %>);

  ==
通过上面的代码可以发现就是把平常正常调用现实的用document.write()调用就可以了。ASP实现起来也是如。评论也是如此,用document.write调用表格显示即可,为了美观可以加上样式。

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值