// protected PlaceHolder ComponentHolder; /// <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 Rainbow.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(); } }
/// <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 Rainbow.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"]; 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(); } } }