Notification - Server Show with New Text

The RadNotification is not updated with AJAX by the button. When the button is clicked the server handler changes the Text property and calls Show() for the RadNotification. The value of Text server property and the shown text are the old ones. If a postback occurs (or the notification is updated by another AJAX request) the new text will be applied to the Text server property and the notification.
The RadNotification is updated with AJAX by the button. When the button is clicked the server handler changes the Text server property and calls Show() for the RadNotification. The value of Text server property and the shown text are the new ones. The new value is kept and shown after subsequent postbacks or AJAX requests.
The RadNotification is not updated with AJAX by the button. When the button is clicked the server handler calls Show(newText) for the RadNotification. The value of Text server property is the old one and the shown text is the new one. If a postback occurs (or the notification is updated by another AJAX request) the new text will not be applied to the Text server property and the notification but the old one will be persistsed.
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

A common scenario is to display new text in the RadNotification at some point. To do so, you can use a client callback, a WebService or change the Text server property.

Changing a server property, however, requires a full postback or to update the whole notification with AJAX.

To display a quick new message once, a Show(string) server method is provided and it does not require that the notification control is a part of the (partial) page rendering. The string can contain HTML.

In this manner you can easily show the notification from the server with any string without caring for AJAX settings or implementing a more complex load on demand mechanism such as callback or WebService.

In this demo, there are three buttons that are placed inside three UpdatePanels. There are also three RadNotifications - one for each button.

When a button is clicked it changes the initial text of its respective notification by including the current time. Depending on the manner of this change, it will either be seen immediately (the second and third buttons), or only after a postback (the first button).

The third button does not change a server property and, therefore, the new text is not persisted after a postback. You can monitor how these changes are carried out via the fourth button that initiates a full page postback.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Notification.ClientSideEvents.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>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container">
        <table cellpadding="0" cellspacing="0" border="0" class="layout">
            <thead>
                <tr>
                    <td style="width: 400px; text-align: center">
                        <label>
                            <strong>Test demo</strong>
                        </label>
                    </td>
                    <td style="width: 400px; text-align: center">
                        <label>
                            <strong>Description</strong>
                        </label>
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <asp:UpdatePanel ID="panel1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <telerik:RadButton RenderMode="Lightweight" runat="server" ID="rb1" Text="Non-ajaxified RadNotification and Show()"
                                    OnClick="btn1_OnClick" Width="380px"></telerik:RadButton>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <telerik:RadNotification RenderMode="Lightweight" ID="n1" runat="server" Text="Initial text" Position="Center"
                                                 AutoCloseDelay="0" Width="350" Height="92" Title="Current time" EnableRoundedCorners="true">
                        </telerik:RadNotification>
                    </td>
                    <td>
                        The RadNotification <strong>is not updated with AJAX</strong> by the button. When
                        the button is clicked the server handler changes the Text property and calls Show()
                        for the RadNotification. <strong>The value of Text server property and the shown text
                            are the old ones</strong>. If a postback occurs (or the notification is updated
                        by another AJAX request) the new text will be applied to the Text server property
                        and the notification.
                    </td>
                </tr>
                <tr class="dark">
                    <td>
                        <asp:UpdatePanel ID="panel2" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <telerik:RadButton RenderMode="Lightweight" ID="rb2" runat="server" Text="Ajaxified RadNotification and Show()"
                                    OnClick="btn2_OnClick" Width="380px" />
                                <telerik:RadNotification RenderMode="Lightweight" ID="n2" runat="server" Text="Initial text" Position="Center"
                                                         AutoCloseDelay="0" Width="350" Height="92" Title="Current time" EnableRoundedCorners="true">
                                </telerik:RadNotification>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                    <td>
                        The RadNotification <strong>is updated with AJAX</strong> by the button. When the
                        button is clicked the server handler changes the Text server property and calls
                        Show() for the RadNotification. <strong>The value of Text server property and the shown
                            text are the new ones</strong>. The new value <em>is</em> kept and shown after
                        subsequent postbacks or AJAX requests.
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:UpdatePanel ID="panel3" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <telerik:RadButton RenderMode="Lightweight" ID="rb3" runat="server" Text="Non-ajaxified RadNotification and Show(newText)"
                                    OnClick="btn3_OnClick" Width="380px" />
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <telerik:RadNotification RenderMode="Lightweight" ID="n3" runat="server" Text="Initial text" Position="Center"
                                                 AutoCloseDelay="0" Width="350" Height="92" Title="Current time" EnableRoundedCorners="true">
                        </telerik:RadNotification>
                    </td>
                    <td>
                        The RadNotification is <strong>not updated with AJAX</strong> by the button. When
                        the button is clicked the server handler calls <strong>Show(newText)</strong> for
                        the RadNotification. <strong>The value of Text server property is the old one and the
                            shown text is the new one</strong>. If a postback occurs (or the notification
                        is updated by another AJAX request) the new text will <em>not</em> be applied to
                        the Text server property and the notification but the old one will be persistsed.
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="postbackCSS">
            <telerik:RadButton RenderMode="Lightweight" ID="RadButton1" runat="server" Text="Perfom a postback" />
        </div>
    </div>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?