November Happy Hour will be moved to Thursday December 5th.

Get page in edit mode from gadget.

Vote:
 

I am trying to get the current page from an IFrameComponent "Gadget" for editing pages. I need to get the curent page in my controler so that i can maipulate the propeties on the page. I have tried 

var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance();
PageReference currentPageLink = pageRouteHelper.PageLink;

But that only returns the start page every time. I need the current page that is being edited. Any help or direction wold help. Thanks, 

#147460
Apr 14, 2016 23:29
Vote:
 

You can try with

            var routeHelper = ServiceLocator.Current.GetInstance<ContentRouteHelper>();           

var currentPageLink = routeHelper.ContentLink;

#147472
Apr 15, 2016 9:11
Vote:
 

GP This is in an edit gadget in the asset pane. So the code that you sugested only returned null. Thank you though. 

#147484
Apr 15, 2016 15:19
Vote:
 

trying a different rout and using dojo to try and get the current context but still geting the same result. the context is the same every time. 

define("epi-cms/component/PageVersions", [
    "epi/shell/_ContextMixin"
        ], function (_ContextMixin) {
            return dojo.declare("epi.cms.component.PageVersions", [_ContextMixin], {
                constructor: function () {
                    dojo.when(this.getCurrentContext(), function (context) {
                        var passedData = { context: context.toString() }
                        $.ajax({
                            url: "/LoremIpsum/CreateLoremIpsum/",
                            method: "post",
                            data: passedData,
                            datatype: "text",
                            success: function (data) {
                                if (data) {
                                    reload(data);
                                }
                            }, complete: function () {
                                self.fetchingNewPage = false;
                            }
                        });
                    });
                }
            });
        });
    }
#147606
Apr 19, 2016 18:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.