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); } }
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); } }