get widget guid on InitializeControls

Posted by Community Admin on 03-Aug-2018 16:08

get widget guid on InitializeControls

All Replies

Posted by Community Admin on 13-Sep-2011 00:00

I am loading 3 custom widgets, that we created on PageLoad.
Each of these widgets are separate instances of the same object - an "AnswerKey"
When these each load I want to get the guid for that instance of the AnswerKey.
In debug, I can see the unique values for each of the properties of that instance of an AnswerKey, such as, answers, title, course; but I can't find the guid.

How do I get the guid for a particular instance of a widget while in the InitializeControls method?

Posted by Community Admin on 15-Sep-2011 00:00

Hello Phil,

Do you mean InitializeControls method of your own widget? Then you first must get a reference to the Page where the widget is, for example:

var manager = PageManager.GetManager();
var page = manager.GetPageNodes().Where(p => p.Title == "Title").FirstOrDefault();
foreach (var control in page.Page.Controls)
    var loaded = manager.LoadControl(control);
    if (loaded is ContentBlock)
        var guid = loaded.ID;

Here I check for ContentBlock, however in your case this will be different.

Kind regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Sep-2011 00:00

Thanks.  I'll be trying that this coming week.

This thread is closed