Navigatie

Contact

Send mail to the author(s) E-mail

View Richard Soeteman's profile on LinkedIn

RSS 2.0 | Atom 1.0 | CDF

Archief

Categorieën

Blogroll

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

Sign In

Zoeken

# Thursday, 05 February 2009
Thursday, 05 February 2009 19:45:52 (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.

 speechbubble

 

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;
   3:   
   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(BasePage.speechBubbleIcon.info, "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" ?> 
<dashBoard>
<section>
    <areas>
        <area>developer</area>
    </areas>

    <tab caption="SpeechBubble">
        <control>/usercontrols/SpeechBubble.ascx</control>
    </tab>
</section>
</dashBoard>

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

Friday, 06 February 2009 10:34:08 (GMT Standard Time, UTC+00:00)
Richard,

Thats really useful. Going to make use of this in future. Many thanks.

Ismail
Ismail Mayat
Thursday, 29 September 2011 08:27:10 (GMT Daylight Time, UTC+01:00)
The post was very helpful. I got the idea of how it works with Umbraco.
Can I cancel out the publishing on the beforepublish event and then show the customize popup?
Currently I could not override the speechBubble, the result is it says "publising was cancelled by a 3rd party add-in".

Please help me on this.
praveity
Monday, 03 October 2011 08:59:26 (GMT Daylight Time, UTC+01:00)
I think (actually pretty sure) it's not possible to override this in an event. The message when an event is canceled is also hard coded so that is something you can't change also. Maybe you could register some javascript and replace the message using JQuery.
Comments are closed.