Only showing notification on certain conditions

3 posts, 1 answers
  1. Chris
    Chris avatar
    17 posts
    Member since:
    Oct 2010

    Posted 19 Jun 2012 Link to this post

    Hi, the RadNotification tool looks extremely useful for my application, but I am having some trouble understanding how to have it do what I want. I want to essentially perform a 'check' every 60 seconds, which will see if there are any new rows in a certain table. if there are, I want to tell the user and show them some details of this row - if not I don't want the notification to show.

    Here's what I have currently:
    function OnClientUpdated(sender, args) {
        var value = sender.get_value();
        if (value == 0) {
            sender.hide();
        }
    }


    <telerik:RadNotification ID="notification" runat="server"
        Title="Incorrect Picking" ShowInterval="30000" KeepOnMouseOver="true" UpdateInterval="30000" AutoCloseDelay="5000" OnClientUpdating="OnClientUpdating" OnClientUpdated="OnClientUpdated" LoadContentOn="TimeInterval" ShowCloseButton="true" Width="250px"
        oncallbackupdate="notification_CallbackUpdate">
        <ContentTemplate>
        <asp:Literal ID="ltlJob" runat="server"></asp:Literal> <asp:ImageButton ID="btnRefresh" runat="server" ImageUrl="~/Content/Images/refresh.png" OnClick="RefreshGrids" />
        </ContentTemplate>
        </telerik:RadNotification>

      protected void notification_CallbackUpdate(object sender, Telerik.Web.UI.RadNotificationEventArgs e)
            {
                LMDBDataContext dc = new LMDBDataContext();
                List<Job> jobs = //Get new jobs
     
                if (jobs.Count > 0)
                {
                    notification.Value = "1";
                    ltlJob.Text = jobs.Count;
                }
                else
                {
                    notification.Value = "0";  
                }
    }

    This 'sort of' works, but the notification pops up for a a very short time then disappears if the value is 0, when I want it to not show it at all.
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 20 Jun 2012 Link to this post

    Hello Chris,

    Since you want the notification to show only on certain conditions I would advise that you remove the automatic showing (i.e. the ShowIinterval property) and in the OnClientUpdated event handler call the show() method if you need it to show instead of calling hide() when you need it not to show. This approach is shown in this online demo. You will see that it has only UpdateInterval configured and LoadContentOn is set to TimeInterval.


    Greetings,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    17 posts
    Member since:
    Oct 2010

    Posted 20 Jun 2012 Link to this post

    That's perfect, thanks!
Back to Top