Problem writing Editor XHTML markup to file

Last post 03-18-2004, 5:54 PM by giantsteps. 4 replies.
Sort Posts: Previous Next
  •  03-05-2004, 12:53 AM 521

    Problem writing Editor XHTML markup to file

    Hi,

     

    Can someone please help me with this code? I had it working OK with another editor. The problem with the other editor was that it didn't write XHTML.

     

    I am trying to read from an xml file into an XmlDocument object, load an xml node with markup from the editor and then write it all back to disk. I am wondering if this isn't working because the button handler I am using is somehow conflicting with the button in the editor?

     

    I've been pouring over the addcustombuttons.aspx sample, but I must be missing something. It would be really great if I could have a save button that saved the editor text to xml. 

     

    I should also mention that I find it difficult to use the code block samples. These seem to be the standard on msdn too. I don't understand this. Isn't code behind supposed to be the greatest thing? It is a pain for me because then I have to horse around trying figure out how to declare something or other to use the sample in my page. I guess this is more of a hassle for me cause I'm new? Does anyone else feel this way? 

     

    From what I have been able to understand the AutoEventWireup property is set to true by default. With codebehind it is set to false. This is making it so hard for me to figure out these buttons! I just don't get when to use onclick and when to use an event handler like below? OK I better stop whinning. Any help would be much appreciated! Thanks.

     

    Peter  

     

    private void Button_Click(object sender, System.EventArgs e)

    {

    //open the file

    XmlReader editReader = new XmlTextReader(File.OpenRead(Server.MapPath("staging/" + editFileName + ".xml")));

     

    //load it into object

    XmlDocument doc = new XmlDocument();

    doc.Load(editReader);

     

    //close file

    editReader.Close();

     

    //find my way to the node that contains my html markup

    XmlElement root = doc.DocumentElement;

    XmlNodeList contentElement = root.GetElementsByTagName("content");

     

    //set xhtml compliant editor markup to equal newly edited contents of node

    contentElement[0].InnerXml = Editor.XHTML;

     

    //write XmlDocument back to the file I opened in the first place

    StreamWriter writer = new StreamWriter(File.Create(Server.MapPath("staging/" + editFileName + ".xml")));

    doc.Save(writer);

    writer.Close();

    }

  •  03-08-2004, 5:45 PM 534 in reply to 521

    Re: Problem writing Editor XHTML markup to file

    giantsteps,

     

    Can you post your whole aspx page and an example xml file?

     

    And what's the problem you really have?


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  03-18-2004, 5:25 PM 580 in reply to 534

    Re: Problem writing Editor XHTML markup to file

    Hi Adam,

     

    My problem is that I can't seem to write the cuteEditor markup to file. As you can see it is executed within a buttonclick event handler. It should work with a blank page that contains only a button control.

     

    The idea is quite simple. I want to take the string of xhtml output from the editor and then write it to disk. I would like it to become the innerxml for an XML document object first before I write the entire XML document object to disk. I think my entire file would simply confuse the issue. Can you just consider that this code operates on its own within a buttonclick hander fired from a simple button on a page with nothing else on it? Thanks.

     

    Peter 

  •  03-18-2004, 5:35 PM 581 in reply to 534

    Re: Problem writing Editor XHTML markup to file

    OK I have another idea. This might be simpler. I can't seem to figure out how to trace my buttonclick event. I have been using Trace but this doesn't seem to work for buttonclick events? Debug doesn't to show me either.

     

    Is there something special I need to do to see my Trace output from a buttonclick event handler? Thanks.

     

    Peter

  •  03-18-2004, 5:54 PM 582 in reply to 534

    Re: Problem writing Editor XHTML markup to file

    ISSUE RESOLVED - PLEASE IGNORE LATEST QUESTIONS
View as RSS news feed in XML