Try our conversational search powered by Generative AI!

call CurrentPage from property type definition

Vote:
 

[PageTypeProperty(
   EditCaption = "My property",
   Required = true,
   Type = typeof(MyCustomPropertyType)
)]
public virtual string MyProperty { get; set; }

Inside my MyCustomPropertyType (subclass of PropertyLongString), can I in any way reference my CurrentPage (which is an instance of the page type
that contains MyProperty)?
(I need this because, based on its PageTypeID, I return a slightly different PropertyDataControl). Any workaround for this?

#149399
May 31, 2016 14:31
Vote:
 

What this gives you back?

ServiceLocator.Current.GetInstance<PageRouteHelper>().Page
#149449
Jun 01, 2016 10:30
Vote:
 

Valdis, thank you! Unfortunately I can't find Service Locator and PageRouteHelper in Epi 6 R2. Sorry for not specifying the version earlier.

#149457
Jun 01, 2016 11:11
Vote:
 

Oh, well. I do not have v6 dlls at hand, but I at least can see that there is "PropertyLongString.PageLink" property in v9. That shold link you back to current page. Do you have similar property in v6?

#149462
Jun 01, 2016 11:28
Vote:
 

Valdis,

This actually works fine when SAVING the page: DataFactory.Instance.GetPage(new PageReference(this.Parent[2].ToString())).PageName.ToString()
but the happiness was short-lived: it breaks when EDITING the page, because the this.parent[2] is evaluated differently then (an id which doesn't exist).
Makes me think this is to do with the fact the page wasn't saved the first time the method was invoked.
Also, another concern is referencing by index [2], in case the index changes in a subsequent Epi version in PropertyDataCollection types.

//later edit: Ah there it is. Can use PageParentLink instead of index 2

#149470
Edited, Jun 01, 2016 13:20
* 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.