1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / get widget guid on InitializeControls

get widget guid on InitializeControls

3 posts, 0 answered
  1. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    13 Sep 2011
    Link to this post
    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?
  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    15 Sep 2011
    Link to this post
    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
  3. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    16 Sep 2011
    Link to this post
    Thanks.  I'll be trying that this coming week.
3 posts, 0 answered