Programmatically retrieve widget settings.
Is there a way to programmatically retrieve settings from a widget on a page? Specifically I want to figure out what the detail template is set to for the Single Item Settings for any given news widget on a page.
Thanks!
Erik,
Runtime settings for widgets on a page are stored in a dictionary property of the PageControl called Properties. However, I believe this dictionary is only populated with properties that are different from the default values.
For an example demonstrating accessing widget properties programmatically, take a look at the Sitefinity Sitemap Module SDK Sample, specifically the SiteMapConfig.cs class which has the following code for locating a NewsView widget and then accessing its properties programmatically.
// retrieve the news view control from the page var newsView = page.Page.Controls.Where(c => c.ObjectType.StartsWith(typeof(NewsView).FullName)).First(); if (newsView == null) continue; // determine if there is a modified control definition var controlDefinition = newsView.Properties.Where(p => p.Name == "ControlDefinition").FirstOrDefault(); if (controlDefinition == null) // control uses default provider providerName = NewsManager.GetDefaultProviderName(); else // search for modified provider name in the control var providerNameProperty = controlDefinition.ChildProperties.Where(p => p.Name == "ProviderName").FirstOrDefault(); if (providerNameProperty == null) // control is modified, but still uses default provider providerName = NewsManager.GetDefaultProviderName(); else // get selected provider name providerName = providerNameProperty.Value; So I looked at the "Sitefinity API Reference" link and I downloaded the SDK but the bat file "Install_Sitefinity API Reference.bat" doesn't exist in it. Is there another way to get this?
Erik, did you run the SDK installer and install the complete package? is there a folder at C:\Program Files (x86)\Telerik\Sitefinity 5.0\SDK\Content\Documents\Chm? this is where the bat file should be.
Sorry, I read the article wrong. I found it now, thanks!