Hello,
I'm trying to add 1 to more webparts to a page based on the amount of folders I have under the page. For example: I have a page called January photos; In the CMS I will have folders under this page for whichever date.
January
-5
-15
-20
So on the page there should be 3 webparts 1 for each date.
On the front page:
<%@ Register Src="~/CMSWebParts/Viewers/Effects/lightbox.ascx" TagName="lightbox" TagPrefix="uc1" %>
<asp:Content ID="Content3" ContentPlaceHolderID="columnTwoContent" Runat="Server">
<div class="galleryLists">
<asp:PlaceHolder runat="server" ID="galleries" visible="false" />
</div>
</asp:Content>
In the code behind I'm attempting this:
string parentNodeAliasPath = CMSContext.CurrentPageInfo.NodeAliasPath.ToLower();
parentNodeAliasPath = parentNodeAliasPath.Trim() + "/%";
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider();
DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, parentNodeAliasPath, CMSContext.CurrentDocument.DocumentCulture, false, "CMS.Folder");
foreach (DataRow dr in ds.Tables[0].Rows)
{
string folderName = dr["NodeName"].ToString();
galleries.Controls.Add(new LiteralControl("<p class='galleryTitle'>" + folderName + "</p>"));
CMSWebParts_Viewers_Effects_lightbox lightbox = new CMSWebParts_Viewers_Effects_lightbox();
lightbox.ID = folderName;
lightbox.ClassNames = "Client.Asset";
lightbox.Path = parentNodeAliasPath.Replace("/%", "/" + folderName);
lightbox.TransformationName = "Client.Asset.ImagesGalleryListView";
lightbox.SelectedItemTransformationName = "Client.Asset.ImagesGalleryDetailedView";
lightbox.LightBoxPermanentNavigation = true;
lightbox.LightBoxGroup = folderName;
galleries.Controls.Add(lightbox);
galleries.Visible = true;
}
However, it crashes with:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 93: {
Line 94: SetValue("ClassNames", value);
Line 95: repItems.ClassNames = value;
Line 96: }
I'm a bit lost at this point. Any help would be appreciated.