void cmdClear_Click(object sender, EventArgs e) { string[] args; SueetieContentPart content = GetContentPart(((Button)sender).CommandArgument, out args); TextBox txtContent = (TextBox)GetControl("txtContent", int.Parse(args[1]), 0); txtContent.Text = content.ContentText; }
private Panel HeaderBuilder(SueetieContentPart content) { Panel header = new Panel(); header.CssClass = "header"; header.Controls.Add(new LiteralControl(string.Format("<span class=\"contentid\">{0}</span>", content.ContentName))); header.Controls.Add(new LiteralControl(string.Format("<span class=\"lastchange\">{0}</span>", content.LastUpdateDateTime))); return(header); }
private Panel EditorBuilder(SueetieContentPart content) { Panel body = new Panel(); body.CssClass = "editor"; TextBox txtContent = new TextBox(); txtContent.ID = "txtContent"; txtContent.TextMode = TextBoxMode.MultiLine; txtContent.Height = new Unit("340px"); txtContent.Width = new Unit("98%"); txtContent.Text = content.ContentText; body.Controls.Add(txtContent); Panel buttons = new Panel(); Button cmdClear = new Button(); cmdClear.Text = "Undo Changes"; cmdClear.ID = string.Concat("Clear_", paneIndex.ToString()); // We use the CommandArguement property to pass data around about which content part we are working on cmdClear.CommandArgument = string.Concat(content.ContentName, "_", paneIndex); cmdClear.Click += new EventHandler(cmdClear_Click); buttons.Controls.Add(cmdClear); Button cmdSave = new Button(); cmdSave.Text = "Save"; cmdSave.ID = string.Concat("Save_", paneIndex.ToString()); // We use the CommandArguement property to pass data around about which content part we are working on cmdSave.CommandArgument = string.Concat(content.ContentName, "_", paneIndex); cmdSave.Click += new EventHandler(cmdSave_Click); buttons.Controls.Add(cmdSave); buttons.CssClass = "contentGridViewPager"; CheckBox chkEditor = new CheckBox(); chkEditor.Text = "HTML Mode"; chkEditor.Attributes.Add("onclick", "ToggleEditor(this);"); chkEditor.Checked = true; // Message is used to display 'Saved' it is a panel so we can add jQuery effects to make it fade etc. Panel subButtons = new Panel(); Panel message = new Panel(); message.ID = "message"; message.CssClass = "ContentSavedMessage"; //buttons.Controls.Add(message); buttons.Controls.Add(chkEditor); body.Controls.Add(buttons); Literal lineBreak = new Literal(); lineBreak.Text = "<div style='clear: both;'></div>"; subButtons.Controls.Add(lineBreak); subButtons.Controls.Add(message); body.Controls.Add(subButtons); return(body); }
private void AddItem(object sender, string sourceLb, string destinationLb) { // Get the content part, ContentName and accordian pane index string[] args; SueetieContentPart content = GetContentPart(((Button)sender).CommandArgument, out args); // Get the ListBox that the item currently resides in ListBox lbSource = (ListBox)GetControl(sourceLb, int.Parse(args[1]), 1); // Get the ListBox to add the item to. Null if just removing an item. ListBox lbDestination = null; if (!string.IsNullOrEmpty(destinationLb)) { lbDestination = (ListBox)GetControl(destinationLb, int.Parse(args[1]), 1); } // Save changes. content.ContentPageID = -1; DbSueetieDataProvider.Provider.UpdateSueetieContentPart(content); }
private Panel ContentBuilder(SueetieContentPart content) { Panel body = new Panel(); body.CssClass = "content"; AjaxControlToolkit.TabContainer tabs = new TabContainer(); tabs.ID = "tabs"; tabs.CssClass = "tabs"; AjaxControlToolkit.TabPanel tabEdit = new TabPanel(); tabEdit.HeaderText = "Edit"; tabs.Tabs.Add(tabEdit); AjaxControlToolkit.TabPanel tabUsers = new TabPanel(); tabUsers.HeaderText = "Users"; // Removed the addition of the Users Tab //tabs.Tabs.Add(tabUsers); UpdatePanel udpEditor = new UpdatePanel(); udpEditor.UpdateMode = UpdatePanelUpdateMode.Always; udpEditor.ChildrenAsTriggers = true; udpEditor.ContentTemplate = new TemplateBuilder(EditorBuilder(content)); tabEdit.ContentTemplate = new TemplateBuilder(udpEditor); body.Controls.Add(tabs); return(body); }
void cmdSave_Click(object sender, EventArgs e) { string[] args; SueetieContentPart sueetieContentPart = GetContentPart(((Button)sender).CommandArgument, out args); TextBox txtContent = (TextBox)GetControl("txtContent", int.Parse(args[1]), 0); Panel message = (Panel)GetControl("message", int.Parse(args[1]), 0); message.Controls.Clear(); try { sueetieContentPart.ContentText = txtContent.Text; sueetieContentPart.ContentPageID = -1; SueetieDataProvider.Provider.UpdateSueetieContentPart(sueetieContentPart); SueetieContentParts.ClearContentPartCache(sueetieContentPart.ContentName); // -1 indicates content parts not associated with Content Pages SueetieContentParts.ClearSueetieContentPartListCache(-1); message.Controls.Add(new LiteralControl("<span>Saved</span>")); } catch { message.Controls.Add(new LiteralControl("<span>Failed</span>")); } }
protected override void OnInit(EventArgs e) { #region Create tinyMCE Script bool TinyMCELoaded = false; foreach (Control _control in this.Page.Header.Controls) { if (_control.GetType().Name == "LiteralControl") { string _js = ((LiteralControl)_control).Text; if (_js.IndexOf("tinyMCE.init") > 0) { int _elementPoint = _js.IndexOf("elements:"); int _endElement = _js.IndexOf("'", _elementPoint); string _newJs = _js.Insert(_endElement + 1, this.ClientID + "_txt" + this.ContentName + ","); LiteralControl _newJsLiteralControl = new LiteralControl(_newJs); this.Page.Header.Controls.Remove(_control); this.Page.Header.Controls.Add(_newJsLiteralControl); TinyMCELoaded = true; } } } if (!TinyMCELoaded) { this.Page.Header.Controls.Add(new LiteralControl(TinyMCEScript.Replace("{0}", this.ClientID + "_txt" + this.ContentName))); } #endregion #region Load Content Part _sueetieContentPart = SueetieContentParts.GetSueetieContentPart(this.ContentName); if (string.IsNullOrEmpty(_sueetieContentPart.ContentText) && this.ContentName != "?69?") { _sueetieContentPart.ContentText = "Empty"; _sueetieContentPart.ContentName = this.ContentName; } else if (this.ContentName == "?69?") { _sueetieContentPart.ContentText = "<b><font color='#FF0000'>No ContentName Specified with Sueetie ContentPart Control</font></b>"; } #endregion #region ImageButton Display Modal Editor ImageButton btnOpen = new ImageButton(); btnOpen.Click += new ImageClickEventHandler(btnOpen_Click); btnOpen.ImageUrl = this.PencilImageUrl; btnOpen.CssClass = this.PencilImageCssClass; if (IsUserEditor() && this.ContentName != "?69?") { this.Controls.Add(btnOpen); } #endregion #region Content Text _text = new LiteralControl(); _text.Text = _sueetieContentPart.ContentText; this.Controls.Add(_text); #endregion #region Panel Creation _panel = new Panel(); _panel.CssClass = windowClass; _panel.ID = "pnl" + this.ContentName; _panel.Height = 590; _panel.Width = 800; #endregion #region DragTop Table Row // Add the table Table table = new Table(); table.CellSpacing = 0; table.CellPadding = 0; table.Width = new Unit("100%"); // Add the title Row TableRow row = new TableRow(); row.CssClass = titleCssClass; // Add th title cell TableCell cell = new TableCell(); cell.Width = 780; cell.Attributes.Add("name", "dragger"); if (iconUrl.Length > 0) { Image img = new Image(); img.CssClass = iconCssClass; img.ImageAlign = ImageAlign.AbsMiddle; img.ImageUrl = iconUrl; cell.Controls.Add(img); } cell.Controls.Add(new LiteralControl(this.title)); row.Controls.Add(cell); TableCell cellClose = new TableCell(); ImageButton btn = new ImageButton(); btn.ImageUrl = closeButtonImageUrl; btn.Click += new ImageClickEventHandler(btn_Click); cellClose.Controls.Add(btn); cellClose.Attributes.Add("text-align", "right"); cellClose.Width = 20; row.Controls.Add(cellClose); table.Controls.Add(row); _panel.Controls.AddAt(0, table); #endregion #region Add Init_Script if (this.ID == null) { this.ID = this.UniqueID; } _panel.Controls.AddAt(0, new LiteralControl(String.Format(INIT_SCRIPT, this.ClientID + "_pnl" + this.ContentName))); #endregion #region Editor Row txtEditor = new TextBox(); txtEditor.ID = "txt" + this.ContentName; txtEditor.Text = _sueetieContentPart.ContentText; txtEditor.Height = new Unit(500); txtEditor.Width = new Unit("100%"); txtEditor.CssClass = "EditorFont"; txtEditor.TextMode = TextBoxMode.MultiLine; TableRow rowbody = new TableRow(); TableCell cellbody = new TableCell(); cellbody.ColumnSpan = 2; rowbody.Controls.Add(cellbody); cellbody.Controls.Add(txtEditor); table.Controls.Add(rowbody); #endregion #region Button Row TableRow rowButtons = new TableRow(); TableCell cellButtons = new TableCell(); cellButtons.ColumnSpan = 2; cellButtons.CssClass = "modalPanelButtonCell"; Button btnSave = new Button(); btnSave.Click += new EventHandler(btnSave_Click); btnSave.CssClass = "modalPanelButtonSave"; btnSave.Text = SueetieLocalizer.GetString("content_save"); Button btnCancel = new Button(); btnCancel.Click += new EventHandler(btnCancel_Click); btnCancel.CssClass = "modalPanelButtonCancel"; btnCancel.Text = SueetieLocalizer.GetString("content_cancel"); cellButtons.Controls.Add(btnCancel); cellButtons.Controls.Add(btnSave); rowButtons.CssClass = "modalPanelButtonRow"; rowButtons.Controls.Add(cellButtons); table.Controls.Add(rowButtons); #endregion this.Controls.Add(_panel); _panel.Visible = false; base.OnInit(e); }