The number of unread messages is synchronously updated with the brushless newest switch style.

Source: Internet
Author: User

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 (uninitialized): (XMLHttpRequest) the object has been created, but the open () method has not been called. // 1 (load): the open () method has been called, but no request has been sent. // 2 (Load completed): The request has been sent. // 3 (interaction): Some response data can be received. // 4 (complete): all data is received and the connection is closed. 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. pa Rse (mMsgCount); Response. write (msgID + ":" + mMsgCount + ']');} else {Response. write (msgID + "messnoread; modification failed") ;}} else {Response. write ("Please try again");} 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 =" New message "> <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();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.