Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Session["username"] == null))
            {
                btnLogin.Text = (string)Session["username"];
            }

            if (Session["pictureName"] == null)
            {
                Response.Redirect("SignIngPage.aspx");
            }

            Objects.PictureCollection pictureCollection = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            List <Objects.Picture>    allPictures       = pictureCollection.allPictures;

            Objects.Picture pictureToDisplay = new Objects.Picture();

            for (int i = 0; i < allPictures.Count; i++)
            {
                if ((string)Session["pictureName"] == allPictures[i].pictureName)
                {
                    pictureToDisplay = allPictures[i];
                    break;
                }
            }

            for (int i = 0; i < pictureToDisplay.categories.Count - 1; i++)
            {
                lblCategories.InnerText = lblCategories.InnerText + pictureToDisplay.categories[i] + ", ";
            }
            lblCategories.InnerText = lblCategories.InnerText + pictureToDisplay.categories[pictureToDisplay.categories.Count - 1];
            imgImage.Src            = "img/" + pictureToDisplay.pictureName;
        }
        protected void btnViewImage_Click(object sender, EventArgs e)
        {
            List <string> categories    = new List <string>();
            string        allCategories = hdnCategories.Value;
            string        filename      = fleNewImage.FileName;

            string[] myCategories = allCategories.Split(',');

            for (int i = 0; i < myCategories.Length - 1; i++)
            {
                categories.Add(myCategories[i]);
            }
            Objects.Picture pictureToAdd = new Objects.Picture(filename, filename, (string)Session["username"], 1, DateTime.Now, categories);

            Objects.PictureCollection allPictures = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            allPictures.add(pictureToAdd);
            HttpRuntime.Cache.Insert("allPictures", allPictures);
            Session["pictureName"] = filename;
            Response.Redirect("ViewImage.aspx");
        }