새로 고침 없는 탄젠트 스타일 동기화 업데이트 읽지 않은 메시지 수

4395 단어 동기
A.aspx
<asp:Repeater ID="rptMessageList" runat="server">

     <ItemTemplate>

         <tr id="trReaded_<%#Eval("RecordID")%>" class="<%#getReadClass(Eval("IsRead").ToString())%>" onclick="MarkMsgRead(<%#Eval("RecordID")%>)">

                                            

           <td class="messcen_tabtd1">  

	   <asp:CheckBox ID="chkItem" runat="server" />

	   <asp:Label ID="lblID" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem, "RecordID")%>'   runat="server"></asp:Label> </td>

 
 
A.aspx
    public string getReadClass(string pIsRead)

    {

        string mReturn = "";

        if (pIsRead == "False")

            mReturn = "messnoread";

        return mReturn;

    }

 
D.js
function MarkMsgRead(pRecordID) {

    try {

        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (err1) {

        try {

            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

        }

        catch (err2) {

            xmlHttp = new XMLHttpRequest();

        }

    }

    //

    var mUrl = "SyschangeStyle.aspx?MsgID=" + pRecordID;

    xmlHttp.open("GET", mUrl, true);

    xmlHttp.onreadystatechange = OnHandlerMsg;

    xmlHttp.send(null);

}



function OnHandlerMsg() {

    //0 (    ): (XMLHttpRequest)      ,      open()  。

    //1 (  ):    open()   ,       。

    //2 (    ):         。

    //3 (  ):           。

    //4 (  ):          ,        。

    if (xmlHttp.readyState == 4) {



        var isValid = xmlHttp.responseText;



        var mMsgCount = document.getElementById("_Header1_lblMsgCount");

        mMsgCount.innerHTML = isValid.substring(isValid.indexOf(':') + 1, isValid.indexOf(']'));



        var mTrID = isValid.substring(0, isValid.indexOf(':'));

        var mTrReadID = "trReaded_" + mTrID;

        var exists = document.getElementById(mTrReadID);

        exists.removeAttribute("className");

    }

}

 
B.aspx.cs
 
    protected void Page_Load(object sender, EventArgs e)

    {

        int msgID = int.Parse(this.Request.QueryString["MsgID"]);

        if (Request.QueryString["MsgID"] != null)

        {

            if (this.changeTrue(msgID))

            {



                string customerID = myShare.GetAObject(true, 0, "CustomerID", "Customers", "UserID='" + Session["UserID"].ToString() + "'").ToString();

                int ReceiverID = int.Parse(customerID);

                string mMsgCount;

                mMsgCount = myShare.GetAObject(true, 0, "count(RecordID)", "MessagesRecord", "IsRead=0 and Deleted=0 and Receiver = " + customerID).ToString();

                int mmMsgCount = int.Parse(mMsgCount);

                Response.Write(msgID + ":" + mMsgCount + ']');

            }

            else

            {

                Response.Write(msgID + "messnoread;    ");

            }

        }

        else

        {

            Response.Write("     ");

        }

    }





    private bool changeTrue(int pmsgID)

    {

        return myShare.SetAField(0, "IsRead", "1", "MessagesRecord", "RecordID=" + pmsgID) != null ? true : false;

    }

 
C.ascx
 
<i>(<a href="SysMessageOld.aspx" title="   "><asp:Label ID="lblMsgCount" runat="server"></asp:Label></a>)</i>

 
C.ascx.cs
 
                string customerID = myShare.GetAObject(true, 0, "CustomerID", "Customers", "UserID='" + Session["UserID"].ToString() + "'").ToString();

                int ReceiverID = int.Parse(customerID);

                lblMsgCount.Text = myShare.GetAObject(true, 0, "count(RecordID)", "MessagesRecord", "IsRead=0 and Deleted=0 and Receiver = " + customerID).ToString();

좋은 웹페이지 즐겨찾기