本文共 2919 字,大约阅读时间需要 9 分钟。
//Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>digg
//Digg.aspx
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;public partial class Digg : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string s = Request["id"].ToString(); int aid = int.Parse(s); if (Request["action"] != null) { string action = Request["action"].ToString(); db d = new db(); if (action == "good") { d.excuteSQL("Update Digg set goodpost=goodpost+1,lastpost=getdate() where contentid=" + aid); } else if (action == "bad") { d.excuteSQL("Update Digg set badpost=badpost+1,lastpost=getdate() where contentid=" + aid); } } string ss = getDigg(aid); Response.Write(ss); } public string getDigg(int strId) { int goodper; int badper; string digg = ""; db d = new db(); DataTable dt = d.getDT("Select goodpost,badpost From Digg where contentid="+strId); foreach (DataRow dr in dt.Rows) { int goodposts = Convert.ToInt32(dr["goodpost"]); int badposts = Convert.ToInt32(dr["badpost"]); if (goodposts + badposts == 0) { goodper = badper = 0; } else { int alls = goodposts + badposts; goodper = Convert.ToInt32((double)goodposts / alls * 100); badper = 100 - goodper; } digg += ""; digg += ""; digg += "顶一下"; digg += "(" + goodposts + ")"; digg += ""; digg += ""; digg += " "; digg += "" + goodper + "%"; digg += ""; digg += ""; } return digg; }}踩一下"; digg += "(" + badposts + ")"; digg += ""; digg += ""; digg += " "; digg += "" + badper + "%"; digg += "
//cookie.js
//读写cookie函数function if "="if ";"if return return nullfunction var new "=" null"" ";expires="
//使设置的有效时间正确。增加toGMTString()
本文转自曾祥展博客园博客,原文链接:http://www.cnblogs.com/zengxiangzhan/archive/2009/10/12/1581788.html,如需转载请自行联系原作者