I created an customfield, the class implemented like below:

public class GoogleMapField :Sitecore.Shell.Applications.ContentEditor.Text, IContentField

In this class I want to get current content itemID is using this customField in ContentEditor. I tried to use ItemID property but It's not success

public string ItemID { get; set; }

This has always been an issue. Using GetItem(), just returns the Content Editor Item in the core Db. What I ended up doing was a bit of a kludge but it works. In my Render method I did this:

var id = !string.IsNullOrEmpty(ItemID)
                        ? ItemID
                        : ControlAttributes.Substring(ControlAttributes.IndexOf("//master/", StringComparison.Ordinal) + 9,
   var item = new ID(id).ToSitecoreItem(db);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.