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

Forums / Developing with Sitefinity / Sitefinity messages using the MessageControl

Sitefinity messages using the MessageControl

4 posts, 0 answered
  1. Trevor Park
    Trevor Park avatar
    7 posts
    Registered:
    10 Mar 2006
    09 Oct 2007
    Link to this post
    Hello All,

    In a sitefinity custom module I use the 

    sfMsg:MessageControl

    control to show messages, but how do I make my own custom messages appear using the MessageContol?

    Bonne Chance,

    Trev

  2. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    10 Oct 2007
    Link to this post
    Hello Trevor Park,

    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. 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.

    Sincerely yours,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Trevor Park
    Trevor Park avatar
    7 posts
    Registered:
    10 Mar 2006
    10 Oct 2007
    Link to this post
    Thanks Vassil,

    Everything works great, but I noticed there are only two types of Modes for a message (Success and Failure).

    Have it ever been considered to add a couple different ones like 'Information' that turns yellow? Does that already exist in 3.1?

    Thanks,

    Trev
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    11 Oct 2007
    Link to this post
    Hi Trevor,

    There are only two Message Modes for now (Success and Error). But your suggestion for additional modes is very useful and we will take it into consideration.

    Greetings,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
4 posts, 0 answered