4

I am trying to do something similar to stackoverflow notification, when you earn a new badge or privilege stackoverflow shows a message at the top of the page until you close the message and then its never shown again.

i can create the message but my question is how to track that the user closed the message and never show it again?

using asp.net 4.0 with jquery.

thanks

Wahtever
  • 3,597
  • 10
  • 44
  • 79

2 Answers2

2

You need to use AJAX and send a notification back into your ASP.net layer and mark the notification as acknowledged in your backing database. (Alternatively, you could use cookies or some other sort of local storage like that available in HTML 5, but I wouldn't recommend it - and I'm sure this isn't the way SO is doing it.)

ziesemer
  • 27,712
  • 8
  • 86
  • 94
2

One approach (if you don't care too much about tracking notifications and who has seen them) is to have a table that stores notifications for users, and then delete that row when they dismiss the notification.

For instance, if they earn a badge:

INSERT INTO NOTIFICATIONS.....

THen when they clear it (via AJAX I assume)

DELETE FROM NOTIFICATIONS...

And on page load you can just collect all the nofications for the current user and display them.

This has the advantage of preventing the 'ever growing table' by only storing records for current notifications and deleting them when they are no longer needed.

Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90