1

How can I show a users' activity count on site title that refreshes automatically like Facebook, LinkedIn, StackOverflow etc.

e.g. in linkedIn I usually see following title on browser to indicate one new activity updated on linkedIn wall.

(1) Imran Rizvi | Linkedin 

I was searching for this question but did not find any solution.

I would if appreciate if anybody could let me know how to do this and with best practice.

James Wiseman
  • 29,946
  • 17
  • 95
  • 158
Imran Rizvi
  • 7,331
  • 11
  • 57
  • 101

2 Answers2

1

You will have to use timer like control which calls a javascript function after a fixed interval like javascript setInterval. In this function you have to send ajax call and get the updates and render the updates with javascript

Here is similar question click

Here is similar functionality could be achieved asp.net ajax toolkit timer control Timer ajax control

Community
  • 1
  • 1
Adil
  • 146,340
  • 25
  • 209
  • 204
1

this should work:

<asp:UpdatePanel runat="server" ID="UpdatePanel1">
        <ContentTemplate>
            <asp:Timer runat="server" ID="Timer1" Interval="5000" OnTick="Timer1_Tick">
            </asp:Timer>
        </ContentTemplate>
    </asp:UpdatePanel>

 protected void Timer1_Tick(object sender, EventArgs e)
 {
     //refresh page title
     Page.Title = "Title refreshed: " + DateTime.Now.ToLongTimeString();
 }
Ashwini Verma
  • 7,477
  • 6
  • 36
  • 56
  • Thanks, I got the idea. I think implementing this through web service would be good practice as it will not need to partial post back and run the whole page life cycle. – Imran Rizvi Apr 23 '12 at 08:37