/// <summary> /// The Page_Load event on this Page is used to obtain the ModuleID /// and ItemID of the event to edit. /// It then uses the Appleseed.ComponentModuleDB() data component /// to populate the page's edit controls with the control details. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // Obtain a single row of event information ComponentModuleDB comp = new ComponentModuleDB(); SqlDataReader dr = comp.GetComponentModule(ModuleID); try { // Read first row from database if (dr.Read()) { TitleField.Text = (string) dr["Title"]; //ComponentField.Text = (string) dr["Component"]; CreatedBy.Text = (string) dr["CreatedByUser"]; DesktopText.Text = (string)dr["Component"]; CreatedDate.Text = ((DateTime) dr["CreatedDate"]).ToShortDateString(); // 15/7/2004 added localization by Mario Endara [email protected] if (CreatedBy.Text == "unknown" || CreatedBy.Text == string.Empty) CreatedBy.Text = General.GetString("UNKNOWN", "unknown"); } } finally { dr.Close(); } } }
/// <summary> /// The UpdateBtn_Click event handler on this Page is used to either /// create or update an event. It uses the Appleseed.EventsDB() /// data component to encapsulate all data functionality. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected override void OnUpdate(EventArgs e) { base.OnUpdate(e); // Only Update if the Entered Data is Valid if (Page.IsValid) { // Create an instance of the Event DB component var comp = new ComponentModuleDB(); comp.UpdateComponentModule(ModuleID, PortalSettings.CurrentUser.Identity.UserName, TitleField.Text, DesktopText.Text); if (Request.QueryString.GetValues("ModalChangeMaster") != null) Response.Write("<script type=\"text/javascript\">window.parent.location = window.parent.location.href;</script>"); else RedirectBackToReferringPage(); } }
/// <summary> /// The Page_Load event handler on this User Control is /// used to load and execute a user control block. /// The user control to execute is stored in the HtmlText /// database table. This method uses the Appleseed.HtmlTextDB() /// data component to encapsulate all data functionality. /// Is a simple variation from HtmlModule. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { // Obtain the selected item from the HtmlText table ComponentModuleDB comp = new ComponentModuleDB(); SqlDataReader dr = comp.GetComponentModule(ModuleID); try { if (dr.Read()) { // Dynamically add the file content into the page string content = (string) dr["Component"]; try { ComponentHolder.Controls.Add(ParseControl(content)); } catch (Exception controlError) { ComponentHolder.Controls.Add (new LiteralControl("<p>Error in control: " + controlError + "<p>" + content)); } } } finally { // Close the datareader dr.Close(); } }