Hide Notification Control

3 posts, 0 answers
  1. dhuss
    dhuss avatar
    120 posts
    Member since:
    Sep 2009

    Posted 02 Aug 2011 Link to this post

    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. dhuss
    dhuss avatar
    120 posts
    Member since:
    Sep 2009

    Posted 02 Aug 2011 Link to this post

    I finally got this figured out. I needed a "OnClientUpdated" in the aspx page as well as setting a value for the notification control.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 03 Aug 2011 Link to this post

    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.

Back to Top