|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
I have this code below, trying to append what I have recently typed into the HTML Editor, but it only contains the original contents of the file and does not contain what I have just typed.
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>"); } }
|
|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
Someone else(Phil Morris ) on this Forum had a similar problem on Wednesday, April 22, 2009 4:55:29 PM. I am looking for the resolution.
Thanks
Kennaxx
|
|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
EO, In your reply to Philip Morris, you told him to move the eo:Scriptmanager outside the CallBackPanel. In my case, I am not using ScriptManager or CallBackPanel.
Thanks
Kennaxx
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi I would set a breakpoint on FileWriteAllText and check whether Editor1.Html has the correct vale. If it does, then it has nothing to with the editor. If it doesn't, then it has nothing to do with your File writting code. In that case you should create a test page to reproduce the problem. You have posted a number of questions but has never posted a full test page that can be used to reproduce the problem. Our position on this is actually quite clear. If you believe there is a problem with the product, you need to create a test page/project to reproduce it. This post explained this in detail: http://www.essentialobjects.com/forum/postst3013_I-run-into-a-problem-can-I-send-over-my-code-so-that-you-can-take-a-look.aspxSo please isolate the problem and post a full test page when you reporting any problem next time. We are not in a position to check or debug your code just because you are using our product. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
I also emailed you a small sample project
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 EOEditorTest { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Editor1.Html = "VORTEX2: The Great Tornado Hunt "+ " What is VORTEX2? "+ " VORTEX2 is the largest field experiment in history to explore the origins, structure and evolution of tornadoes. "+ " The VORTEX2 teams will be looking to understand how, when and why tornadoes form. Answers to these questions "; }
protected void Editor1_Save(object sender, EventArgs e) { DirectoryInfo Folder = new DirectoryInfo(Server.MapPath("~/Images")); if (Folder.Exists) { if (Editor1.Html != string.Empty) { string FilePathSave = Folder.ToString() + "profile.txt"; 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>"); } } } }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EOEditorTest._Default" %>
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <eo:Editor ID="Editor1" runat="server" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Height="320px" HighlightColor="255, 255, 192" onsave="Editor1_Save" 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> </div> </form> </body> </html>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have looked into the code. The problem is that you reset the Editor's contents in your Page_Load. Page_Load is called when your page renders initially, but it is also called when your page posts back to trigger the server event. So the sequence of event in your case is:
1. User types some text; 2. User clicks Save button; 3. The Editor carries the correct contents, including whatever user has entered, back to the server; 4. Page_Load is called. Your code overwrote the correct contents here; 5. Editor1_Save is called. You see the contents that you set because whatever user has entered is already lost on step 4;
In order resolve this issue, you should put the code inside a If Not Page.IsPostBack condition. You will only set the Editor's contents when the page is not posting back. That would skip step 4.
This is a very general ASP.NET behavior and a very common code mistake. You can try the same with a simple ASP.NET TextBox and you will see the same problem.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 4/30/2009 Posts: 36
|
EO,
Thanks for your answer.
Kennaxx
|
|