New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Update on Interval

The RadNotification in this demo is configured to update on every 3 seconds. The example simulates a scenario of checking for new messages at specified interval—if there are new messages, the notification is shown. Otherwise it does not show.

Event log

RadNotification can be configured to update automatically at a specified interval without being shown. Here is how to achieve this:

  • Set LoadContentOn="TimeInterval"
  • Set the UpdateInterval property to the desired interval in milliseconds

Note: You can set the Value property in the callback and read it after that on the client to determine whether to show or not the notification as done in this demo.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Notification.UpdateInterval.DefaultCS" %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <script type="text/javascript">
        function OnClientUpdated(sender, args) {
            var message = "Update (check) was done!";
            var newMsgs = sender.get_value();
            if (newMsgs != 0) {
                sender.show();
                message += (newMsgs == 1) ? (" There is 1 new message!") : (" There are " + newMsgs + " new messages!");
            } else {
                message += " There are no new messages!";
            }
            logEvent(message);
        }
    </script>
    <div class="demo-container size-medium">
        <p>
            The RadNotification in this demo is configured to update on every 3 seconds. The
            example simulates a scenario of checking for new messages at specified interval—if
            there are new messages, the notification is shown. Otherwise it does not show.
        </p>
    </div>
    <qsf:eventlogconsole id="EventLogConsole1" runat="server" allowclear="true"></qsf:eventlogconsole>
    <telerik:RadNotification RenderMode="Lightweight" id="RadNotification1" runat="server" loadcontenton="TimeInterval"
        width="300" height="150" animation="Fade" enableroundedcorners="true" enableshadow="true"
        onclientupdated="OnClientUpdated" title="Received messages" offsetx="-20" offsety="-20"
        titleicon="none" updateinterval="3000" autoclosedelay="1500" oncallbackupdate="OnCallbackUpdate">
        <ContentTemplate>
            <asp:Literal ID="lbl" runat="server"></asp:Literal>
        </ContentTemplate>
    </telerik:radnotification>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance