Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(MyPhotoGallery));

        // create the JS Arrays for autopopulating Tags from cats
        CategoryTagsArrays = GenerateCategoryTagsArrays();

        string strPage = Request.Params["p"];

        CurrentPageIndex = Pager.TryGetPageIndex(strPage);

        member = (Member)Session["Member"];

        string strPhotoCollectionDeleteID = Request.Params["d"];
        string strReload = Request.Params["reload"];

        if (strPhotoCollectionDeleteID != null)
        {
            PhotoCollection photoCollection = PhotoCollection.GetPhotoCollectionByWebPhotoCollectionID(strPhotoCollectionDeleteID);

            if (photoCollection != null)
            {
                if (photoCollection.MemberID == member.MemberID)
                {
                    photoCollection.Delete();
                }
            }
        }

        DefaultWebPhotoCollectionID = Request.Params["pc"];

        // hack to reload photocollection
        member.PhotoCollection = null;

        // if a photocollectionid has been specified then load the new collection
        if (DefaultWebPhotoCollectionID != null && !IsPostBack)
        {
            PhotoCollection photoCollection = PhotoCollection.GetPhotoCollectionByWebPhotoCollectionID(DefaultWebPhotoCollectionID);
            if (photoCollection.MemberID == member.MemberID)
            {
                DefaultPhotoCollectionID            = photoCollection.PhotoCollectionID;
                Session["DefaultPhotoCollectionID"] = DefaultPhotoCollectionID;
                Bind(CurrentPageIndex);
            }
        }
        else if (!IsPostBack && DefaultWebPhotoCollectionID == null)
        {
            // get the default photo collectionid on initial load
            DefaultPhotoCollectionID            = member.PhotoCollection[0].PhotoCollectionID;
            DefaultWebPhotoCollectionID         = member.PhotoCollection[0].WebPhotoCollectionID;
            Session["DefaultPhotoCollectionID"] = DefaultPhotoCollectionID;
            Bind(CurrentPageIndex);
        }

        DefaultPhotoCollectionID = (int)Session["DefaultPhotoCollectionID"];

        GenerateGalleries();
    }