Get page in edit mode from gadget.


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, 

Apr 14, 2016 23:29

You can try with

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

var currentPageLink = routeHelper.ContentLink;

Apr 15, 2016 9:11

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

Apr 15, 2016 15:19

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", [
        ], function (_ContextMixin) {
            return dojo.declare("epi.cms.component.PageVersions", [_ContextMixin], {
                constructor: function () {
                    dojo.when(this.getCurrentContext(), function (context) {
                        var passedData = { context: context.toString() }
                            url: "/LoremIpsum/CreateLoremIpsum/",
                            method: "post",
                            data: passedData,
                            datatype: "text",
                            success: function (data) {
                                if (data) {
                            }, complete: function () {
                                self.fetchingNewPage = false;
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.