Try Now
More in this section

Forums / Developing with Sitefinity / Set page title from custom widget

Set page title from custom widget

1 posts, 0 answered
  1. michael
    michael avatar
    17 posts
    15 Nov 2015
    06 Jan
    Link to this post

    Hi there,

    I am trying to create a custom widget that can be dropped onto a page, and allow the user to modify that pages title from within the widgets designer (rather than going to page properties and doing it in there).

    I couldn't see how this can be done in the .cs of the designer, so I'm attempting to do this via hooking into the PageManager.Executing event.

    I can successfully get a ControlProperty object in the event (when e.CommandName == "CommitTransaction").  I can grab the Value from that object, which I now want to set as the corresponding pages title.

    Is there any way to get the id of the page that the widget is sitting on from the PageManager.Executing event from the ControlProperty object?  

    Not sure if it's even possible, or if there is perhaps a better way of acheiving this?

    ... here is the relevant code from my event handler ...

                if (e.CommandName == "CommitTransaction" || e.CommandName == "FlushTransaction")
                    var provider = sender as PageDataProvider;
                    var dirtyItems = provider.GetDirtyItems();
                    if (dirtyItems.Count != 0)
                        foreach (var item in dirtyItems)
                            //Can be New, Updated, or Deleted
                            SecurityConstants.TransactionActionType itemStatus = provider.GetDirtyItemStatus(item);

                            var controlProp = item as ControlProperty;
                            if (controlProp != null)
                                if (controlProp.Name == "Message")
                                    // THIS IS WHERE I WANT TO SET THE PAGE TITLE TO controlProp.Value



1 posts, 0 answered