/// ----------------------------------------------------------------------------- /// <summary> /// cmdUpdate_Click runs when the update button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void cmdUpdate_Click(object sender, EventArgs e) { try { DnnTestController objDnnTests = new DnnTestController(); DnnTestInfo objDnnTest = new DnnTestInfo(); objDnnTest.ModuleId = ModuleId; objDnnTest.ItemId = ItemId; objDnnTest.Title = txtTitle.Text; objDnnTest.Content = txtContent.Text; objDnnTest.CreatedByUser = this.UserId; if (Null.IsNull(ItemId)) { // add the content within the DnnTest table objDnnTests.AddDnnTest(objDnnTest); } else { // update the content within the DnnTest table objDnnTests.UpdateDnnTest(objDnnTest); } // Redirect back to the portal home page Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// ----------------------------------------------------------------------------- protected void Page_Load(object sender, System.EventArgs e) { try { DnnTestController objDnnTests = new DnnTestController(); List <DnnTestInfo> colDnnTests; // get the content from the DnnTest table colDnnTests = objDnnTests.GetDnnTests(ModuleId); if (colDnnTests.Count == 0) { // add the content to the DnnTest table DnnTestInfo objDnnTest = new DnnTestInfo(); objDnnTest.ModuleId = ModuleId; objDnnTest.Title = Localization.GetString("DefaultTitle", LocalResourceFile); objDnnTest.Content = Localization.GetString("DefaultContent", LocalResourceFile); objDnnTest.CreatedByUser = this.UserId; objDnnTests.AddDnnTest(objDnnTest); // get the content from the DnnTest table colDnnTests = objDnnTests.GetDnnTests(ModuleId); } // bind the content to the repeater lstContent.DataSource = colDnnTests; lstContent.DataBind(); } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void Page_Load(object sender, System.EventArgs e) { try { // Determine ItemId of DnnTest to Update if ((Request.QueryString["ItemId"] != null)) { ItemId = Int32.Parse(Request.QueryString["ItemId"]); } // If this is the first visit to the page, bind the role data to the datalist if (Page.IsPostBack == false) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); if (!Null.IsNull(ItemId)) { // get content DnnTestController objDnnTests = new DnnTestController(); DnnTestInfo objDnnTest = objDnnTests.GetDnnTest(ModuleId, ItemId); if ((objDnnTest != null)) { txtTitle.Text = objDnnTest.Title; txtContent.Text = objDnnTest.Content; ctlAudit.CreatedByUser = objDnnTest.CreatedByUserName; ctlAudit.CreatedDate = objDnnTest.CreatedDate.ToString(); } else { // security violation attempt to access item not related to this Module Response.Redirect(Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; ctlAudit.Visible = false; } } } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdDelete_Click runs when the delete button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void cmdDelete_Click(object sender, EventArgs e) { try { // Only attempt to delete the item if it exists already if (!Null.IsNull(ItemId)) { DnnTestController objDnnTests = new DnnTestController(); objDnnTests.DeleteDnnTest(ModuleId, ItemId); } // Redirect back to the portal home page Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }