protected void Page_Load(object sender, EventArgs e) { // First load tasks if (!IsPostBack) { // Initialize the manager object manager = new AssignmentManager(); // Fetch the page ict_Page page = manager.GetPageByID(pageID); // Configure the page content editor and the user interface if (page != null) { litContent.Text = page.Content; editor.Text = litContent.Text; tbTitle.Text = page.Title; ViewState["PageTitle"] = page.Title; } else { litContent.Text = ""; editor.Text = litContent.Text; tbTitle.Text = ""; ViewState["PageTitle"] = ""; } } Page.Title = ViewState["PageTitle"] as string; // Author tasks if (Page.User.IsInRole("Author")) { // Show the editing control strip pnlControl.Visible = true; // Configure the visibility of the buttons to match the view/edit mode btnEdit.Visible = !pnlEdit.Visible; btnView.Visible = btnPageContent.Visible = btnMediaList.Visible = btnMediaUpload.Visible = pnlEdit.Visible; // Update the user interface lblStatus.Text = ""; // The following block will capture the intent of the editor's "save" icon // Clicking the icon in the CKEditor causes a postback // Therefore, we will check here to see if the content and title have changed // If yes, we will save the changes, and update the user interface string editorText = editor.Text; string literalText = litContent.Text; string textboxTitle = tbTitle.Text.Trim(); string viewstateTitle = ViewState["PageTitle"] as string; if ((editorText != literalText) | (textboxTitle != viewstateTitle)) { // Save the changes manager = new AssignmentManager(); manager.UpdatePageContentByID(pageID, textboxTitle, editorText); // Update the user interface Page.Title = textboxTitle; ViewState["PageTitle"] = textboxTitle; litContent.Text = editorText; lblStatus.Text = "Changes have been saved"; } } // Author tasks } // Page_Load
protected void Page_Load(object sender, EventArgs e) { // First load tasks if (!IsPostBack) { // Initialize the manager object manager = new AssignmentManager(); // Fetch the page ict_Page page = manager.GetPageByID(pageID); // Configure the page content editor and the user interface if (page != null) { litContent.Text = page.Content; editor.Text = litContent.Text; tbTitle.Text = page.Title; ViewState["PageTitle"] = page.Title; } else { litContent.Text = ""; editor.Text = litContent.Text; tbTitle.Text = ""; ViewState["PageTitle"] = ""; } } Page.Title = ViewState["PageTitle"] as string; // Author tasks if (Page.User.IsInRole("Author")) { // Show the editing control strip pnlControl.Visible = true; // Configure the visibility of the buttons to match the view/edit mode btnEdit.Visible = !pnlEdit.Visible; btnView.Visible = btnPageContent.Visible = btnMediaList.Visible = btnMediaUpload.Visible = pnlEdit.Visible; // Update the user interface lblStatus.Text = ""; // The following block will capture the intent of the editor's "save" icon // Clicking the icon in the CKEditor causes a postback // Therefore, we will check here to see if the content and title have changed // If yes, we will save the changes, and update the user interface string editorText = editor.Text; string literalText = litContent.Text; string textboxTitle = tbTitle.Text.Trim(); string viewstateTitle = ViewState["PageTitle"] as string; if ((editorText != literalText) | (textboxTitle != viewstateTitle)) { // Save the changes manager = new AssignmentManager(); manager.UpdatePageContentByID(pageID, textboxTitle, editorText); // Update the user interface Page.Title = textboxTitle; ViewState["PageTitle"] = textboxTitle; litContent.Text = editorText; lblStatus.Text = "Changes have been saved"; } } // Author tasks }