This is a migrated thread and some comments may be shown as answers.

Only showing notification on certain conditions

2 Answers 120 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 19 Jun 2012, 07:59 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 20 Jun 2012, 10:38 AM
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.
0
Chris
Top achievements
Rank 1
answered on 20 Jun 2012, 07:30 PM
That's perfect, thanks!
Tags
Notification
Asked by
Chris
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Chris
Top achievements
Rank 1
Share this question
or