Set page title from custom widget

Posted by Community Admin on 04-Aug-2018 03:15

Set page title from custom widget

All Replies

Posted by Community Admin on 06-Jan-2016 00:00

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
                           
                       

Thanks,
Michael

 

This thread is closed