Notification

Controls

Rate this demo

Thank you for your post!
Submit a support ticket
If you have an active license or trial, you have access to dedicated support from Telerik’s developers. Response time is 24h for active licenses and 72h for trials, Mon-Fri.
Post in the forums
If you don’t have access to support or would like to help other people by sharing your problem, reach out to our active community in the forums.

Notification - Callback support

Notifier
Elizabeth Lincoln
Roland Mendel
Yoshi Tannamuri
Catherine Dewey
Jean Fresnière
Georg Pipps
Pascale Cartrain

Click on a person to see whteher he/she is available for an online conversation.

Callback support


RadNotification can be configured to perform a callback to update its content which in general leads to an improved performance. To configure the RadNotification to use a callback, you should assign a handler to its OnCallbackUpdate server event. In addition, you can pass a value from the client to the server and from the server - back to the client as this demo does.

Here is how to do this in more details:

  • Pass a value from client to server . To do this, you should set the desired value to the notification client object. In this demo, the OnClientShowing event is used due to the used configuration. In general - when the update() method is called (no matter internally or explicitly) the last assigned value is passed. To read the value on the server, you shoould use the arguments object of the OnCallbackUpdate event handler.

  • Pass a value from OnCallbackUpdate event handler to the client. In the common case, any settings in a callback will not be persistsed in ViewState and will not be passed to the client and this is how callbacks work (if the control was not additionally updated e.g with AJAX). RadNotification, however, allows to pass a string value. To do so, you should simply set that value to the RadNotification's Value property. After that you can read the value on the client in the OnClientUpdated event.

  • The callback functionality and the OnCallbackUpdate are available and work both for simple and rich content. In the case of simple content, you can directly change the Text and ContentIcon property in the callback without using AJAX to update the notification. In teh case of rich content (ContentTemplate) used, any changes you make on the content controls, will be automatically applied, again without need to use an AJAX request.
C# VB
Show code in new window Demo isolation steps
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Notification.Callback.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>ASP.NET Notification Demo - Callback support</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
    <script type="text/javascript">
        function ShowNotification(arg) {
            var notification = $find("<%=RadNotification1.ClientID %>");
            notification.set_value(arg);
            notification.show();
        }
    </script>
    <div class="notWrapper">
        <div class="notTitle">
            Notifier</div>
        <div class="notCont">
            <asp:Repeater runat="server" ID="itemsRepeater" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <div onclick='<%# String.Format("ShowNotification(\"{0};{1}\")" , Eval("CustomerID"),Eval("ContactName") ) %>'
                        class="notItems">
                        <div class="notThumb" style="background-image: url('<%# Eval("CustomerID", "Img/{0}.jpg") %>');">
                        </div>
                        <div class="notName">
                            <%# Eval("ContactName") %>
                        </div>
                        <div>
                            <%# GetNote((((System.Data.DataRowView)Container.DataItem)["ContactName"]).ToString())%>
                        </div>
                        <div style="clear: both">
                        </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT CustomerID, ContactName FROM [Customers] 
                    WHERE Country = 'Austria' OR Country = 'Belgium' OR 
                    Country = 'Canada'"></asp:SqlDataSource>
    <telerik:RadNotification ID="RadNotification1" runat="server" Width="320" Animation="Fade"
        EnableRoundedCorners="true" EnableShadow="true" Style="z-index: 35000" LoadContentOn="EveryShow"
        VisibleTitlebar="false" OnCallbackUpdate="OnCallbackUpdate" OffsetX="-20" OffsetY="-20">
        <ContentTemplate>
            <div style="margin: 10px 5px 5px 5px;">
                <div class="userImg">
                    <asp:Image ID="img" runat="server" alt=""></asp:Image></div>
                <div class="userInfo">
                    <asp:Label ID="lblName" runat="server" class="userName"></asp:Label>
                    <br />
                    <span class="userOffline">offline</span>
                    <asp:Label ID="notificationLbl" runat="server" class="userData"></asp:Label>
                </div>
            </div>
        </ContentTemplate>
    </telerik:RadNotification>
    <br />
    </form>
</body>
</html>