November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
public void BuildPages()
{
_selectedPages = new PageDataCollection();
//= if there is no saved value, there are no selected pages
if(String.Length == 0)
return;
String[] pageIds = String.Split(',');
PageData page = null;
//= iterate through the ids stored in string and try to create a PageData
//= object. If we succeed, add page to the _selectedPages
foreach (String pageId in pageIds) {
page = EPiServer.Global.EPDataFactory.GetPage( new PageReference( int.Parse(pageId) ) );
if ( page != null)
_selectedPages.Add(page );
}
}
///
///
///
///
///
private bool PageIsContained(PageData page)
{
foreach(PageData pageToCheck in _selectedPages)
if (pageToCheck.PageLink.ID == page.PageLink.ID)
return true;
return false;
}
public override void CreateChildControls(string renderType,System.Web.UI.Control container)
{
BuildPages();
switch(renderType)
{
case "edit":
//= source the root for the colours from a dynamic property on the
//= start page
DynamicProperty prop = DynamicProperty.Load(EPiServer.Global.EPConfig.StartPage, "ColourList");
PageReference colourRef = (PageReference)prop.PropertyValue.Value;
if (colourRef == PageReference.EmptyReference)
throw new Exception("Missing: Dynamic ColourList as a Page Reference");
//= get the children of the dynamic property as our list of colours
PageDataCollection pages = EPiServer.Global.EPDataFactory.GetChildren(colourRef);
//= add each colour to the checkbox list
CheckBoxList propertyList = new CheckBoxList();
propertyList.RepeatColumns = 5;
foreach(PageData page in pages)
{
ListItem item = new ListItem(page.PageName, page.PageLink.ID.ToString());
//= if the page (colour) is in the selectedPages, then selected = true
item.Selected = PageIsContained( page);
propertyList.Items.Add(item);
}
CopyWebAttributes(container,propertyList);
container.Controls.Add(propertyList);
propertyList.Controls.Add(CreateParseValidator(propertyList));
break;
default:
Label properties = new Label();
StringBuilder builder = new StringBuilder();
foreach(PageData page in _selectedPages)
builder.Append(page.PageName).Append(',');
CopyWebAttributes(container,properties);
if(builder.Length > 0)
properties.Text = builder.Remove(builder.Length - 1, 1).ToString();
container.Controls.Add(properties);
break;
}
}
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 79: Line 80: DynamicProperty prop = DynamicProperty.Load(EPiServer.Global.EPConfig.StartPage, "ColourList"); Line 81: PageReference colourRef = (PageReference)prop.PropertyValue.Value; Line 82: Line 83: if (colourRef == PageReference.EmptyReference)
Any ideas?