Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Cute Editor for .NET
»
HowTo: Get ceToolbar Custom Object Values
HowTo: Get ceToolbar Custom Object Values
Last post 11-26-2004, 2:47 PM by
cutechat
. 3 replies.
Sort Posts:
Oldest to newest
Newest to oldest
Previous
Next
11-25-2004, 5:02 PM
2595
KenA
Joined on 01-11-2004
Posts 66
HowTo: Get ceToolbar Custom Object Values
Reply
Quote
Hi. I´ve inserted a TextBox in the CE Toolbar in order to create a MailForm. [ I want the msg field and the tbxEmail fields in one single object, eg: CuteEditor ] according to the following pic:
Now when I press the Save btn I need to get the value in the tbxEmail field, but how?
I´m trying:
private void ce1_PostBackCommand(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
if( string.Compare(e.CommandName,"Save",true)==0 )
{
/ / Check tbxEmail???
// this.ce1.ToolControls.IndexOf("tbxEmail");
???
}
}
Any tips?
Regards,
»»» KenA
11-26-2004, 11:19 AM
2602
in reply to
2595
cutechat
Joined on 07-22-2004
Posts 2,332
Re: HowTo: Get ceToolbar Custom Object Values
Reply
Quote
KenA :
I just write a sample for you :
aspx:
<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %> <%@ Page language="c#" Codebehind="TextBox1.aspx.cs" AutoEventWireup="false" Inherits="CuteEditorWeb.HowTo.RegisterCustomButton.TextBox1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>TextBox1</title> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="FlowLayout"> <form id="Form1" method="post" runat="server"> <asp:Label id="Label1" runat="server">Command Message Here</asp:Label><BR> <CE:EDITOR id="Editor1" runat="server" TemplateItemList="[Save,Bold,Italic,JustifyLeft,JustifyRight,JustifyCenter]/[MyHolderName]"></CE:EDITOR> </form> </body> </HTML>
aspx.cs:
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace CuteEditorWeb.HowTo.RegisterCustomButton { public class TextBox1 : System.Web.UI.Page { protected CuteEditor.Editor Editor1; #region Web Auto Gen override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Editor1.PostBackCommand += new System.Web.UI.WebControls.CommandEventHandler(this.Editor1_PostBackCommand); this.Editor1.TextChanged += new System.EventHandler(this.Editor1_TextChanged); this.Load += new System.EventHandler(this.Page_Load); } #endregion protected System.Web.UI.WebControls.Label Label1; protected TextBox tbxMail; private void Page_Load(object sender, System.EventArgs e) { Label lblSendTo=new Label(); lblSendTo.Text=" TO : "; Editor1.ToolControls["MyHolderName"].Control.Controls.Add(lblSendTo); //create a new instance and set it to the class field tbxMail=new TextBox(); tbxMail.ID="tbxMail"; tbxMail.Style["vertical-align"]="middle"; //listen it's event (if you want) tbxMail.TextChanged+=new EventHandler(tbxMail_TextChanged); //add tbxMail to the MyHolderName specified by the editor1.TemplateItemList Editor1.ToolControls["MyHolderName"].Control.Controls.Add(tbxMail); } private void tbxMail_TextChanged(object sender, EventArgs e) { //Assert sender==tbxMail } private void Editor1_TextChanged(object sender, System.EventArgs e) { } private void Editor1_PostBackCommand(object sender, System.Web.UI.WebControls.CommandEventArgs e) { if(string.Compare(e.CommandName,"Save",true)==0) { string mail=tbxMail.Text.Trim(); if(mail.Length==0) { Label1.ForeColor=Color.DarkRed; Label1.Text="Please input the e-mail address!"; } else { Label1.ForeColor=Color.Empty; Label1.Text="This mail has been sent to : "+mail; } return; } } } }
If you have any questions about this sample , please reply this thread .
Regards , Terry .
11-26-2004, 1:42 PM
2608
in reply to
2602
KenA
Joined on 01-11-2004
Posts 66
Re: HowTo: Get ceToolbar Custom Object Values
Reply
Quote
Thanks Terry,
Actually being able to insert a 'Holder' as a atributte of CE tag makes things easy. Before that I was doing something like:
System.Web.UI.WebControls.TextBox tbxEmail = new System.Web.UI.WebControls.TextBox(); tbxEmail.ID = "tbxEmail"; tbxEmail.Width = 200; tbxEmail.Style["position"] = "relative"; tbxEmail.Style["top"] = "2px"; tbxEmail.Style["left"] = "1px"; ce1.AddToolControl("tbxEmail", tbxEmail);
And in the ce1_PostBackCommand
if( string.Compare(e.CommandName,"Save",true)==0 ) { // Check tbxEmailText : tbxEmail is inside the CuteEditor Toolbar! IEnumerator IE = this.ce1.ToolControls.GetEnumerator(); int i=0; while( i<this.ce1.ToolControls.Count ) { IE.MoveNext(); if( this.ce1.ToolControls[i].Name == "tbxEmail" ) { TextBox tbx = new TextBox(); tbx = (TextBox)this.ce1.ToolControls[i].Control; tbxEmailText = tbx.Text.Trim(); break; } i++; } //... etc }
Regards,
»»» KenA
11-26-2004, 2:47 PM
2614
in reply to
2608
cutechat
Joined on 07-22-2004
Posts 2,332
Re: HowTo: Get ceToolbar Custom Object Values
Reply
Quote
Yes .
What you need to do , is put this
"System.Web.UI.WebControls.TextBox tbxEmail"
as the class member .
and change the statement to
"this.tbxEmail = new System.Web.UI.WebControls.TextBox();"
for the
"while( i<this.ce1.ToolControls.Count ){ ... }"
you could use the
TextBox tb=(TextBox)=this.ce1.ToolControls["tbxEmail"].Control;
instead .
if you have change the tbxEmail to the class member ,
" this.tbxEmail " would be the best way .
Regards , Terry .