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();