Creating multiple galleries programtically

  •  02-25-2011, 9:29 PM

    Creating multiple galleries programtically

    Hello.  I have an aspx page that needs to be populated with a variable number of galleries based on user settings.  By default, there is one gallery that is implemented statically and all of the rest are implemented
    programmatically.  Also, each gallery needs to have a different Gallery Folder.  The problem is that when I try to add files to one of the programmatically implemeted galleries, the admin console shows the images from the static gallery.  In order words if I try to upload an image into one of the galleries created programmatically is just goes to into the static gallery.  Below is a sample of my source code. 
     
    For the static gallery.
     
     C#
     GalleryBrowser1.AllowEdit=true;
     
    Aspx
     <%if(GalleryBrowser1.AllowEdit){%>
                            <a href="#" onclick="thegallerybrowser.ShowEditor();return false;">Upload Photos</a> |
                        <%}%>
                            <a href="#" onclick="thegallerybrowser.ShowSlider();return false;">View as slide show</a>
                        </div>
                        <dotnetgallery:gallerybrowser runat="server" id="GalleryBrowser1" Width="780" Height="400" />
     
    For the Dynamically Created Galleries
     
    DotNetGallery.GalleryBrowser gallery = new DotNetGallery.GalleryBrowser();
                    gallery.GalleryFolder = @"~/GalleryFiles/" + _profileUser.UserName + sport.sportName.Trim() + @"/";
                    gallery.ID = sport.sportName.Trim();
                    gallery.LogonUserName = HttpContext.Current.Profile.UserName;
                    gallery.Viewer = "LightBox";
                    gallery.ConsoleLayout = "Explorer";
                    gallery.Theme = "Classic";
                    gallery.Layout = "Classic";
                    
                    
                    gallery.AllowEdit = true;
                    Literal galleryControlLiteral = new Literal();
                    StringBuilder gallerySb = new StringBuilder("<a href=");
                    gallerySb.Append('"');
                    gallerySb.Append("#");
                    gallerySb.Append('"');
                    gallerySb.Append("onclick=");
                    gallerySb.Append('"');
                    gallerySb.Append("thegallerybrowser.ShowEditor();return false;");
                    gallerySb.Append('"');
                    gallerySb.Append(">Upload New Pictures</a>");

                    galleryControlLiteral.Text = gallerySb.ToString();

                    if (_isUsersOwnProfile)
                    {
                        page.Controls.Add(literal);
                    }
                    page.Controls.Add(gallery);
                    page.Controls.Add(galleryControlLiteral);
                    ASPxPageControlSports.TabPages.Add(page);
     
    Any help figuring this out would be greatly appreciated.  
     
    Thanks in Advance. 
    Filed under:
View Complete Thread