Get current content ID from field control?
In a field control, is there a way to get the parent content ID of the field control? For example, how would I get the content object or ID from inside InitializeControls of a field control?
public
class
MyCustomFieldControl : FieldControl
protected
override
void
InitializeControls(GenericContainer container)
var contentItem =
this
.???????
I am after this answer too Urgently...any solution?
Weird but true, The best I have reached is to read the parent dynamic content from the query string
#region Methods
protected
override
void
InitializeControls(GenericContainer container)
//I already know the type of the parent although you can find it too in the querystring
Type parentType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.MobileHomeData.Productfinder"
);
//Reading parent GUID from the querystring , Then getting this parent record
var master = dynamicModuleManager.GetDataItem(parentType,
new
Guid(Page.Request.QueryString[
"parentId"
]));
//Now simply read the value you are looking for form the parent record
var prodTypeTitle = master.GetValue<Lstring>(
"ProductType"
).Value;
You guys get anywhere on this? I have a custom field on the Events module that uses a custom field control and I'd like to get the id of the event I'm currently editing when the control loads.
Alright, I figured this one out. Since I was working with events, I went to Admin -> Settings -> Events -> Controls -> EventsBackend -> Dialogs -> ContentViewEditDialog, then in the Parameters attribute you can see all the params that get returned when you request the query string. So just add &id=Id and then in your field control:
var stringId = HttpContext.Current.Request.QueryString["id"]