asp.net类似QQ、人人的即时消息提醒

js代码:

var counter="<%=counter %>" ;
function getNewDyns() {
            $.post("NewDyn.ashx", { "count": counter }, function(data, status) {
            if (status == "success" && data>0) {
                    $("#newDynTip").html("您有"+ data + "条新消息!");
                }
            })
        }


前台部分代码:
<div  class="center"><a href="javascript:location='Home.aspx'" id="newDynTip"></a></div>

NewDyn.ashx后台代码:
using System;
using System.Web;
using System.Web.SessionState;

using BLL;


namespace Zone.owner
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>

    public class NewDyn : IHttpHandler,IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int record=-1;
            int oldCount = Convert.ToInt32(context.Request["count"]);
            DynBLL.GetPaged(100,1,ref record,Convert.ToInt32(context.Session["userID"]));
            context.Response.Write(record-oldCount);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

运行效果:
asp.net类似QQ、人人的即时消息提醒_第1张图片

你可能感兴趣的:(asp.net类似QQ、人人的即时消息提醒)