|
Rank: Member Groups: Member
Joined: 4/23/2009 Posts: 23
|
I cannot get Editor1.HTML to return the modified text. Always returns the unmodified text. Please advise.
I am doing this from the save event.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Did you set the editor's Html property in your Page_Load? If you do, you need to enclose it in an "If Not Page.IsPostBack" conditionl block.
Thanks
|
|
Rank: Member Groups: Member
Joined: 4/23/2009 Posts: 23
|
Yes, I only load the Edito1.HTML if not postback.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Then we will need you to create a test page that reproduces the problem. Please make sure the page runs independently. We will then run that at here and see what we can find.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
Jon Miller,
I had the same problem. I have attached my own .cs. I hope it helps you.
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO;
namespace PixShax.Pages { public partial class EditPage : System.Web.UI.Page { //private int GroupId; //private string MemberId; //private string AboutUs; //private string ContactUs; private string MemberSvrUrl; private string Folder; private string InFile; protected void Page_Load(object sender, EventArgs e) { //this.MemberId = Session["FileMan_MemberId"] = ; this.MemberSvrUrl = Convert.ToString( Session["FileMan_MemberSvrUrl"]); this.InFile = "\\profile.txt"; if (!IsPostBack) { LoadIntoEditor(); /* Today is Memorial Day. It is a day to remember the fallen. My heart goes out * to all those who lost loved one in all wars and in any other event.*/ } else {
} } protected void Editor1_Save(object sender, EventArgs e) { DirectoryInfo Folder = new DirectoryInfo(Server.MapPath(MemberSvrUrl)); if (Folder.Exists) { if (Editor1.Html != string.Empty) { string FilePathSave = Folder.ToString() + this.InFile; File.WriteAllText(FilePathSave, Editor1.Html); } else { Response.Write("<script language='javascript'>window.alert('Please enter file name');</script>"); } } else { Response.Write("<script language='javascript'>window.alert('Folder not found');</script>"); } } private void LoadIntoEditor() { if (File.Exists(Server.MapPath(MemberSvrUrl) + this.InFile)) { Editor1.Html = File.ReadAllText(Server.MapPath(MemberSvrUrl) + "\\profile.txt"); } else { Response.Write("<script language='javascript'>window.alert('File not found');</script>"); } }
} }
|
|
Rank: Member Groups: Member
Joined: 4/23/2009 Posts: 23
|
Thanks, My code is similar to yours. The only thing I am doing different(not shown in yours) create the save event....
Editor1.Save += new EventHandler( Editor_Save );
This is placed in page_load outside the !IsPostback{} ??? Perhaps this is my problem.?? Jon
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Jon,
Wherever you hook up Save event will not affect what you get out of Editor.Html property. Try to isolate the issue into a test page and we should be able to tell you what's wrong very quickly.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/23/2009 Posts: 23
|
Here is the .cs side using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient;
public partial class Rector_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string user; try { user = Membership.GetUser().ToString(); } catch { //ignore user =""; }
if (!Page.IsPostBack) { this.Editor1.Html = Message("Carol"); // Only load text first time } else { } // all loads, do .... switch( user ) { case "Jon": case "Carol": // This is edit mode this.Editor1.Visible = true; string junk = this.Editor1.Html; this.Editor1.Save += new EventHandler(Editor1_Save); break; default: // This is display only mode string html = "<center>"; html += Message("Carol"); html += "</center>"; this.Editor1.Visible = false; this.Label1.Text = html; break; }
}
void Editor1_Save(object sender, EventArgs e) { //throw new NotImplementedException();
string username; username = "Carol"; Response.Write("Save" + this.Editor1.Html);
string junk = sender.ToString(); // for debug
string sqlSAVE; sqlSAVE = "UPDATE eve27301.dbo.SJ_Page SET Page = @Page ," + " DateEdited = @Date " + "WHERE Username = '" + username + "'"; SqlParameter parmPage = new SqlParameter("@Page", SqlDbType.VarChar,4000 ); SqlParameter parmDate = new SqlParameter("@Date", SqlDbType.DateTime); parmDate.Direction = ParameterDirection.Input; parmPage.Direction = ParameterDirection.Input;
SqlCommand cmdSAVE = new SqlCommand(sqlSAVE, Connection); cmdSAVE.Parameters.Add(parmDate); cmdSAVE.Parameters.Add(parmPage);
cmdSAVE.Connection.Open(); parmDate.Value = DateTime.Now.ToString(); parmPage.Value = this.Editor1.Html.ToString();
cmdSAVE.ExecuteNonQuery(); cmdSAVE.Connection.Close(); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Your code looks fine to us. We tested the following code and it works fine:
Code: HTML/ASPX
<form id="form1" runat="server">
<div>
<eo:Editor runat="server" ID="Editor1" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Height="320px" HighlightColor="255, 255, 192" ToolBarSet="Full" Width="500px">
<FooterStyle CssText="border-right: gray 1px solid; padding-right: 2px; border-top: gray 1px; padding-left: 2px; padding-bottom: 2px; border-left: gray 1px solid; padding-top: 2px; border-bottom: gray 1px solid; background-color: #fafafa" />
<BreadcrumbItemStyle CssText="border-right: darkgray 1px solid; padding-right: 3px; border-top: darkgray 1px solid; margin-top: 1px; padding-left: 3px; font-size: 12px; padding-bottom: 1px; border-left: darkgray 1px solid; padding-top: 1px; border-bottom: darkgray 1px solid; font-family: tahoma" />
<EmoticonStyle CssText="background-color:white;border-bottom-color:#c5d3ed;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#c5d3ed;border-left-style:solid;border-left-width:1px;border-right-color:#c5d3ed;border-right-style:solid;border-right-width:1px;border-top-color:#c5d3ed;border-top-style:solid;border-top-width:1px;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;" />
<BreadcrumbItemHoverStyle CssText="border-right: darkgray 1px solid; padding-right: 3px; border-top: darkgray 1px solid; margin-top: 1px; padding-left: 3px; font-size: 12px; padding-bottom: 1px; border-left: darkgray 1px solid; padding-top: 1px; border-bottom: darkgray 1px solid; font-family: tahoma; background-color:#e0e0e0;" />
<HeaderStyle CssText="border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid; border-bottom: gray 1px" />
<BreadcrumbItemSeparatorStyle CssText="width: 3px; height: 10px" />
<EmoticonDropDownStyle CssText="border-top: gray 1px solid; border-right: gray 1px solid; padding-right: 2px; border-top: gray 1px; padding-left: 2px; padding-bottom: 2px; border-left: gray 1px solid; padding-top: 2px; border-bottom: gray 1px solid; background-color: #fafafa" />
<BreadcrumbLabelStyle CssText="padding-right: 6px; padding-left: 6px; font-size: 12px; padding-top: 1px; font-family: tahoma" />
<BreadcrumbDropDownStyle CssText="border-top: gray 1px solid; border-right: gray 1px solid; padding-right: 2px; border-top: gray 1px; padding-left: 2px; padding-bottom: 2px; border-left: gray 1px solid; padding-top: 2px; border-bottom: gray 1px solid; background-color: #fafafa" />
<TabButtonStyles>
<NormalStyle CssText="border-right: #335ea8 1px; padding-right: 7px; border-top: #335ea8 1px; padding-left: 7px; font-size: 12px; padding-bottom: 3px; border-left: #335ea8 1px; padding-top: 3px; border-bottom: #335ea8 1px; font-family: tahoma; background-color: white" />
<HoverStyle CssText="border-right: #335ea8 1px solid; padding-right: 6px; border-top: #335ea8 1px solid; padding-left: 6px; font-size: 12px; padding-bottom: 2px; border-left: #335ea8 1px solid; padding-top: 2px; border-bottom: #335ea8 1px solid; font-family: tahoma; background-color: #c2cfe5" />
<SelectedStyle CssText="border-right: #335ea8 1px solid; padding-right: 6px; border-top: #335ea8 1px solid; padding-left: 6px; font-size: 12px; padding-bottom: 2px; border-left: #335ea8 1px solid; padding-top: 2px; border-bottom: #335ea8 1px solid; font-family: tahoma; background-color: white" />
</TabButtonStyles>
<EditAreaStyle CssText="border-right: gray 1px solid; padding-right: 0px; border-top: gray 1px solid; padding-left: 0px; padding-bottom: 0px; border-left: gray 1px solid; padding-top: 0px; border-bottom: gray 1px solid" />
</eo:Editor>
<asp:Label runat="server" ID="Label1">
</asp:Label>
</div>
</form>
Code: C#
protected void Page_Load(object sender, EventArgs e)
{
string user = "Carol";
if (!Page.IsPostBack)
{
this.Editor1.Html = "Carol";
// Only load text first time
}
else
{
}
// all loads, do ....
switch (user)
{
case "Jon":
case "Carol":
// This is edit mode
this.Editor1.Visible = true;
string junk = this.Editor1.Html;
this.Editor1.Save += new EventHandler(Editor1_Save);
break;
default:
// This is display only mode
string html = "<center>";
html += "Carol";
html += "</center>";
this.Editor1.Visible = false;
this.Label1.Text = html;
break;
}
}
void Editor1_Save(object sender, EventArgs e)
{
Label1.Text = Editor1.Html;
}
Our code is slighlty different than yours on: 1. We hardcoded user as "Carol" in Page_Load; 2. We do not have Message function, so we skipped it; 3. We removed all code in your Editor1_Save. We only check Editor1.Html here; None of those changes should affect getting HTML value. Please try the above code and see if it works for you. If it does, then the problem has to do with other elements in your page. Try to isolate the problem into a test page that can run independently so that we can reproduce the problem here. See here about the general guidance about test code: http://www.essentialobjects.com/forum/postst3013_I-run-into-a-problem-can-I-send-over-my-code-so-that-you-can-take-a-look.aspxMake sure you submit a complete test page including both the .cs file and .aspx file. Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/23/2009 Posts: 23
|
Interesting...
void Editor1_Save(object sender, EventArgs e) { Label1.Text = Editor1.Html; // Inserting this line made things work???
string username; username = "Carol";
string sqlSAVE; sqlSAVE = "UPDATE eve27301.dbo.SJ_Page SET Page = @Page ," + " DateEdited = @Date " + "WHERE Username = '" + username + "'"; SqlParameter parmPage = new SqlParameter("@Page", SqlDbType.VarChar, 4000); SqlParameter parmDate = new SqlParameter("@Date", SqlDbType.DateTime); parmDate.Direction = ParameterDirection.Input; parmPage.Direction = ParameterDirection.Input;
SqlCommand cmdSAVE = new SqlCommand(sqlSAVE, Connection); cmdSAVE.Parameters.Add(parmDate); cmdSAVE.Parameters.Add(parmPage);
cmdSAVE.Connection.Open(); parmDate.Value = DateTime.Now.ToString(); parmPage.Value = this.Editor1.Html.ToString();
cmdSAVE.ExecuteNonQuery();
cmdSAVE.Connection.Close(); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I do not believe the first line is what made it to work. But I would think you can always use that line as a test line to verify whether the Editor is functioning correctly.
Thanks!
|
|