Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • webangelo 107 posts 190 karma points
    Jan 21, 2010 @ 19:35
    webangelo
    0

    How do I do create a speech bubble from an event?

    I was playing with this in the Lvl. 2 Certification class and have an answer for the Move event which mostly works (I'll post it as a reply) but I'm interested in any refinements or better ways to do this.  The publish event seemed to override this so it isn't complete, yet but the method I'll post allows you to get access to the Page object from the event.

  • webangelo 107 posts 190 karma points
    Jan 21, 2010 @ 19:38
    webangelo
    2

    So this is what I'm currently doing for the AfterMove event, which works... mostly.  Please note you do have to hook the event up.

     

    void Document_AfterMove(object sender, MoveEventArgs e)
    {
    Page page = ((Document)sender).HttpContext.Handler as Page;
    ((BasePage)page).speechBubble(BasePage.speechBubbleIcon.success, "Title", "Message");
    }
  • Daniel Bardi 923 posts 2554 karma points
    Feb 04, 2010 @ 11:27
    Daniel Bardi
    0

    There is no need for the Document reference.  Here is a static method I have used to handle event exceptions.  Just call it in a try catch and pass in the exception.

            private static void ShowErrorBubble(string title, Exception exception)

            {

                ((BasePage)HttpContext.Current.Handler).speechBubble(BasePage.speechBubbleIcon.error, title, exception.Message);

            }

  • Daniel Bardi 923 posts 2554 karma points
    Feb 04, 2010 @ 11:28
    Daniel Bardi
    0

    Here's prettier code:

      private static void ShowErrorBubble(string title, Exception exception)
            {
                ((BasePage)HttpContext.Current.Handler).speechBubble(BasePage.speechBubbleIcon.error, title, exception.Message);
            }

  • Daniel Bardi 923 posts 2554 karma points
    Feb 04, 2010 @ 11:33
    Daniel Bardi
    0

    One more time:

    private static void ShowErrorBubble(string title, Exception exception)
    {
           ((BasePage)HttpContext.Current.Handler).speechBubble(BasePage.speechBubbleIcon.error, title, exception.Message);        
    }

     

Please Sign in or register to post replies

Write your reply to:

Draft