/// <summary> /// Binds the form. /// </summary> private void BindForm() { bool pageExists = false; if (PageId > 0) { using (IDataReader reader = FileTreeItem.GetItemById(PageId)) { if (reader.Read()) { pageExists = true; Name.Text = reader["Name"].ToString(); IsDefault.IsSelected = (bool)reader["IsDefault"]; MasterPageText.Text = (reader["MasterPage"] != DBNull.Value) && (reader["MasterPage"] != null) ? (string)reader["MasterPage"] : String.Empty; } reader.Close(); } // Load meta attributes using (IDataReader reader = PageAttributes.GetByPageId(PageId)) { if (reader.Read()) { txtTitle.Text = (string)reader["Title"]; txtKeywords.Text = (string)reader["MetaKeys"]; txtDescription.Text = (string)reader["MetaDescriptions"]; } else { // add default site attributes PageAttributes.Add(PageId, GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId), GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId)); txtTitle.Text = GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId); txtKeywords.Text = GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId); txtDescription.Text = GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId); } reader.Close(); } } if (!pageExists) { // update UI for creating a new page BindParentFolderList(); ParentFolderRow.Visible = true; } // since mater page is not used anywhere for now, hide it alway MasterPageRow.Visible = false; }
/// <summary> /// Creates a new page. /// </summary> private void CreatePage() { int newId = 0; string newPageName = MakePageName(Name.Text); //create new page string guid = Guid.NewGuid().ToString(); newId = FileTreeItem.AddFileItem(guid, true, false, false, MasterPageText.Text, SiteId); FileTreeItem.MoveTo(newId, int.Parse(Root.SelectedValue)); FileTreeItem.UpdateFileItem(newId, newPageName, true, true, false, MasterPageText.Text, SiteId); //append meta description and keywords PageAttributes.Add(newId, String.IsNullOrEmpty(txtTitle.Text) ? GlobalVariable.GetVariable(_GlobalVariableTitleKey, SiteId) : txtTitle.Text, String.IsNullOrEmpty(txtKeywords.Text) ? GlobalVariable.GetVariable(_GlobalVariableMetaKeywordsKey, SiteId) : txtKeywords.Text, String.IsNullOrEmpty(txtDescription.Text) ? GlobalVariable.GetVariable(_GlobalVariableMetaDescriptionKey, SiteId) : txtDescription.Text); }