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

Hide Notification Control

2 Answers 175 Views
Notification
This is a migrated thread and some comments may be shown as answers.
dhuss
Top achievements
Rank 1
dhuss asked on 02 Aug 2011, 05:00 PM

I am using the Notification control to alert our users that are logged into our system of when we will be doing maintenance. I plan on using a simple text file (server side) that will have the contents to display. If the file has text, the notification will display it to the user. If the file is empty, then do not show the notification to the user. I have code in the "OnCallbackUpdate" sub to read the file. If the message is empty I set the notification control to visible = false. However, it still shows up on the screen. How do I make it not show when there isn't any text to display?

<telerik:RadNotification ID="RadNotification1" runat="server" LoadContentOn="EveryShow"
    ShowInterval="6000" OnCallbackUpdate="OnCallbackUpdate" Position="Center" VisibleTitlebar="False"
    AutoCloseDelay="5000" EnableRoundedCorners="True" EnableShadow="True" Skin="Office2010Black">
</telerik:RadNotification>

Protected Sub OnCallbackUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadNotificationEventArgs)
    Dim sMsg As String = ""
    Dim sr As System.IO.StreamReader = New System.IO.StreamReader("C:\temp\TextFile1.txt")
    sMsg = sr.ReadToEnd
    sr.Close()
    If Not String.IsNullOrEmpty(sMsg.Trim) Then
        RadNotification1.Text = sMsg
    Else
        RadNotification1.Visible = False
    End If
End Sub

2 Answers, 1 is accepted

Sort by
0
dhuss
Top achievements
Rank 1
answered on 02 Aug 2011, 08:19 PM
I finally got this figured out. I needed a "OnClientUpdated" in the aspx page as well as setting a value for the notification control.
0
Svetlina Anati
Telerik team
answered on 03 Aug 2011, 09:44 AM
Hello Dhuss,

 
A quick follow up:

1) If you decide to use OnClientUpdated, you could use LoadContentOn="TimeInterval" and UpdateInterval, no need to set any ShowInterval in this case and you will getter a better performance. A sample demo of this approah is available below:

http://demos.telerik.com/aspnet-ajax/notification/examples/updateinterval/defaultcs.aspx

2) You could keep the ShowInterval but instead of using OnClientUpdated, you could also use OnClientShowing, determine whether to cancel the show and if so - call args.set_cancel(true).

More information about this event is available below:

http://www.telerik.com/help/aspnet-ajax/radnotification-on-client-showing.html

Kind regards,
Svetlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Notification
Asked by
dhuss
Top achievements
Rank 1
Answers by
dhuss
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or