Image folder with subfolders

Sep 7, 2010 at 4:46 PM

If you try to assign a media folder that contains subfolders it comes up with an error message on the page with the macro, I think it's because it assumes everything on the folder is an image. Anyway of catching this?

 


Object reference not set to an instance of an object.

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: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   Designit.Umb.Gallery.WebUi.usercontrols.Designit.Gallery.ShowGallery.repImages_ItemDataBound(Object sender, RepeaterItemEventArgs e) +400
   System.Web.UI.WebControls.Repeater.OnItemDataBound(RepeaterItemEventArgs e) +108
   System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +136
   System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +443
   System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +51
   System.Web.UI.WebControls.Repeater.DataBind() +75
   Designit.Umb.Gallery.WebUi.usercontrols.Designit.Gallery.ShowGallery.Page_Load(Object sender, EventArgs e) +940
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 

Oct 6, 2010 at 9:29 AM


Ok, been playing with the source a bit, and I have a fix for you.  In the repImages_ItemDataBound event handler method, add the following code snippet:

            if (currentImage.ContentType.Alias != "Image")
            {
                e.Item.Visible = false;
                return;
            }

right after

var currentImage = (Media)e.Item.DataItem;

Recompile, replace the dll, and voila, images are displayed, and everything else (files, folders) is ignored, and the error isn't thrown...