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();
}