Send mail to the author(s) E-mail

View Richard Soeteman's profile on LinkedIn

RSS 2.0 | Atom 1.0 | CDF




The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Sign In


# Thursday, February 5, 2009
Thursday, February 5, 2009 7:45:52 PM (GMT Standard Time, UTC+00:00) ( Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

One of the things I like most about Umbraco is that you can extend it in a way that your custom functionality has exactly the same behaviour as the standard Umbraco functionality. The biggest compliment you can get from a user is when they say "I found a bug in Umbraco" while it's your own control (or love the way Umbraco works when it's your own control)..  One of the things to achieve that is to use the same mechanism to show messages to the user as Umbraco does. In this post we create a simple user control where the user can type a message and we will show that message using the Umbraco Speech bubble mechanism as shown in the image below.



To build this we need to create a standard WebUserControl called SpeechBubble.ascx. In the ascx file we add the following code that creates the UI and hooks up an Event Handler for the submit button.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SpeechBubble.ascx.cs" Inherits="SpeechBubble" %>
Message:<asp:TextBox ID="MessageTextBox" runat="server"></asp:TextBox> <asp:Button ID="SpeechButton" runat="server" onclick="SpeechButton_Click" Text="Submit" />

In the Code Behind file we will add the following code:

   1:  using System;
   2:  using umbraco.BasePages;
   4:  public partial class SpeechBubble : System.Web.UI.UserControl
   5:  {
   6:      protected void SpeechButton_Click(object sender, EventArgs e)
   7:      {
   8:          if (Page is BasePage)
   9:          {
  10:              //Okay we are in Umbraco
  11:              ((BasePage)Page).speechBubble(, "Message", MessageTextBox.Text);
  12:          }
  13:      }
  14:  }

We will run this code as an Dashboard Control which runs in the Umbraco context. Therefore we can cast the Page Type to a the Umbraco BasePage type and then use the speechBubble method which displays the message. If you want to play with this yourself, you can download the usercontrol here. Add the files in this zip file to the UserControl folder of Umbraco  and Modifiy the Dashboard.Config file which you can find in the Config folder:

<?xml version="1.0" encoding="utf-8" ?> 

    <tab caption="SpeechBubble">

Then when you login to Umbraco and go to the developer section you can send messages to yourself. Have fun.