How to find Widgets (Editor) Zones

TRISHUL TANDEL asked on December 5, 2018 20:14

How to find Widgets (Editor) Zones.

I need to find how many widget added on my current page and also wants to access there's properties values. I need c# code for this.

Any Idea anyone have ? Please help.

Recent Answers

David te Kloese answered on December 6, 2018 14:46 (last edited on December 6, 2018 21:42)

It's a bit older code but try something like this:

// you could replace the following line with just getting the current page
var pageInfo = PageInfoProvider.GetPageInfo(SiteContext.CurrentSiteName, "/SomeAliasPath", "en_US", "/", true);

var zone = pageInfo.TemplateInstance.WebPartZones.First(z => z.ZoneID == "yourzoneid");
var webPart = zone.WebParts.First(w => w.ControlID.ToLower() == "yourwidgetcodename");

var webPartValue = webPart.GetValue("SomeCustomProperty");
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.