1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Telerik.Cms.Web.UI.MessageControl

Telerik.Cms.Web.UI.MessageControl

2 posts, 0 answered
  1. Dave
    Dave avatar
    76 posts
    Registered:
    10 Mar 2008
    06 May 2008
    Link to this post
    This is a pretty neat control.  For those that don't know, it's the "status bar" type control used in the Admin section, that fades from gradients of green (success) or red (failure) and displays a message after a save attempt (and other postbacks).

    I'd like to use it in my module, and I've messed around with it, but I can't seem to find a proper way to reset it or make sure it disappears after it's served its purpose.  Anyone else had success using this?
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 May 2008
    Link to this post
    Hi Dave,

    In order to have a working message control, you should declare it in an .ascx or .aspx file in the following way:

    <sfMsg:MessageControl runat="server" ID="messageCtrl">  
        <ItemTemplate> 
            <asp:Label runat="server" ID="messageText"></asp:Label> 
        </ItemTemplate> 
    </sfMsg:MessageControl> 

    Note that the label with "messageText" id is a required control used to show the message text.

    If you are adding the control dynamically to the controls collection and you are not providing template to its ItemTemplate property, it would use its default template which has exactly the same controls structure as the code declaration above.

    The Message Control is visible only when the Message property of the control has a value different from null or empty in the OnPreRender phase. So, if you set up the Message property to empty on PreRender, the control will not be shown at all.
    In other words, if you run the code below in some controls event or a page load event, it will show you the "Hello World" text:

    MessageControl msgCtrl = new MessageControl();  
    msgCtrl.Message = "Hello World!";  
    msgCtrl.Mode = MessageMode.Success; 

    The Mode property is used to indicate whether the text should be shown in red or green highlighting text.


    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered