Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
2.71/5 (3 votes)
See more:
I want to create a notification alert similar to that of facebook (new message notification at the top in tiny red square). I googled a lot but i could not find anything helpful. Can you please explain how this can be achieved?
Posted
Comments
Monster Maker 26-Mar-13 2:18am    
Can you give reference of the project, where u have to use that?
arbaaz jalil 26-Mar-13 2:25am    
I am developing a site which has social networking features such as nested comments and friend requests. I have solved the friend request and nested comment part but i want to display a notification every time someone posts something on my wall. So it is pretty much like facebook.
bbirajdar 26-Mar-13 2:31am    
Create a webservice and call it from the client side with javascript timer
arbaaz jalil 26-Mar-13 2:37am    
@aspnet_regiis i am a beginner. Can you provide some tutorial or references which can help me do what you are suggesting me to do?
bbirajdar 26-Mar-13 2:49am    
Search on google for these terms -
call asp.net webservice from javascript

javascript timer

Well in that case telling you in precise,

The concept of notifications in social network,

Every activity that you do ...has associated entities(users) with it.

And whenever the activity is performed the associated users are notified.


So the solution for this(what i do) is,

making a table of activity in database, which stores the entities(users) that are associated

with it and table of notifications for a perticular user. When any new tuple of that activity

is added(when any user performs that activity), then the notifications table for the associated

user is updated(telling about the activity time, and who initiated it,etc).


Finaly, when the user opens his account, the notifications are fetched from the table and

displayed. This is how it can be done(not the best way mind you).
 
Share this answer
 
Comments
arbaaz jalil 26-Mar-13 2:45am    
Thanks, for your reply but i still do not know how to "display" that number (notification) in a fancy way. And how to make it disappear once the notification has been clicked at.
Here Will go->
1)create div or span where you need to display the notification say div with id "divResult"


2)use following javascript to http request using jquery post method

JavaScript
<script type="text/javascript">

    $(document).ready(function () {
        window.setInterval(function () {
            searchSearch('helo');
        }, 5000);
    });
    function searchSearch(strVal) {
        alert(strVal);
        $.post("../HttpHandler/SearchAll.ashx", { 'id': '1', 'Status': strVal }, function (response) {
            $('#divResult').html(response);

        });
    }
</script>

Observe above script there in $(document).ready where i am calling SearchSearch function for every 5seconds (5000 mili seconds=5 sec).
in SearchSearch function you can pass the UserId and check at backedn how manyRecords inserted for this userId.
NO in $.post(..../HttpHandler)
I am requesteing to this searchAll.ashx page which is http handler
and also passing the parameter values there u can pass userid
3)http Handler .ashx
in this file
The above request wil directly come to this methode where in context you can find the paramter values which you are passing in $.post() methode as Status fetch value
VB
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
       strStatus = context.Request("Status")
       If strStatus = "Search" Then
     'Code for fetching the notification details from database
       End If
       context.Response.ContentType = "text/plain"
       context.Response.Write(strResult)
   End Sub

where strResult is the variabble value you want to send back to request as response


Hope This may Help -Happy coding
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900