Beispiel #1
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    BTBRandomImageInfo objBTBRandomImage = new BTBRandomImageInfo();
                    objBTBRandomImage = ((BTBRandomImageInfo)CBO.InitializeObject(objBTBRandomImage, typeof(BTBRandomImageInfo)));

                    int fileId = Int32.Parse(ctlURL.Url.Substring(7));

                    FileController fileController = new FileController();
                    FileInfo       fi             = fileController.GetFileById(fileId, this.PortalId);
                    objBTBRandomImage.imageSrc = fi.Folder + fi.FileName;
                    objBTBRandomImage.imageAlt = txtAlt.Text;
                    objBTBRandomImage.moduleID = this.ModuleId;
                    objBTBRandomImage.Url      = ctlLink.Url;

                    BTBRandomImageController objCtlBTBRandomImage = new BTBRandomImageController();
                    objCtlBTBRandomImage.Add(objBTBRandomImage);

                    //update the url DNN table with the URL parameters
                    UrlController urlController = new UrlController();
                    urlController.UpdateUrl(this.PortalId, ctlLink.Url, ctlLink.UrlType, false, false,
                                            this.ModuleId, ctlLink.NewWindow);

                    DataBindList();
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #2
0
        private void cmdDeleteImage_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            string selectedImage = lstImages.SelectedValue;

            if (selectedImage != null && selectedImage != String.Empty)
            {
                try
                {
                    int imageId = Int32.Parse(selectedImage);
                    BTBRandomImageController controller = new BTBRandomImageController();
                    controller.Delete(imageId);

                    DataBindList();
                }
                catch (FormatException ex)
                {
                    //we've not got a valid int in the lstImage value
                    Exceptions.ProcessModuleLoadException(this, ex);
                }
                catch (Exception ex)
                {
                    Exceptions.ProcessModuleLoadException(this, ex);
                }
            }
        }
Beispiel #3
0
        private void DataBindList()
        {
            BTBRandomImageController objCtlBTBRandomImage = new BTBRandomImageController();

            ArrayList images = objCtlBTBRandomImage.GetByModules(this.ModuleId);

            lstImages.DataSource = images;
            lstImages.DataBind();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                BTBRandomImageController objBTBRandomImage = new BTBRandomImageController();
                ArrayList listImage;
                int       upperLimit;

                if (!Page.IsPostBack)
                {
                    listImage = objBTBRandomImage.GetByModules(ModuleId);

                    if (listImage.Count == 0)
                    {
                        //no images loaded hide the image control
                        //we're done here
                        imgRandom.Visible = false;
                        return;
                    }

                    //pick a random image from the arraylist and display it
                    upperLimit = listImage.Count;

                    Random             rand     = new Random((int)DateTime.UtcNow.Ticks);
                    BTBRandomImageInfo objImage = (BTBRandomImageInfo)listImage[rand.Next(upperLimit)];

                    imgRandom.Visible       = true;
                    imgRandom.AlternateText = objImage.imageAlt;
                    imgRandom.ImageUrl      = PortalSettings.HomeDirectory + objImage.imageSrc;

                    //check if we have an URL stored for this image and display the link as
                    //required
                    if (objImage.Url != null && objImage.Url != String.Empty)
                    {
                        //hlImage.Visible = true;
                        hlImage.NavigateUrl = Globals.LinkClick(objImage.Url, TabId, ModuleId, false);
                        if (objImage.NewWindow)
                        {
                            hlImage.Target = "_blank";
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }