I hope you guys can help me out here.
I have an application written in C#, that uses a WebBrowser control to edit HTML files (marked with 2 on the screenshot), and here's the code that initializes it:
htmlEditor.DocumentText = "";
doc = htmlEditor.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
htmlEditor.Url = new Uri(Properties.Main.Default.tempDir + "\\section-1.html");
I also have a listview control, that shows the list of HTML files(marked with 1 on the screenshot). Each time the user clicks on a list item, an event is triggered and the webbrowser control loads a different HTML file, and here's the code for that:
private void sectionsTree_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
{
Sections.fileCheck();
if (sectionsTree.SelectedNode != null)
{
emDataSet.dtSectionsDataTable sectionsDT = new emDataSet.dtSectionsDataTable();
sectionsDT.ReadXml(Properties.Main.Default.tempDir + "\\sections.xml");
for (int i = 0; i < sectionsDT.Rows.Count; i++)
{
if (sectionsTree.SelectedNode.Text == sectionsDT.Rows[i][2].ToString())
{
htmlEditor.Url = new Uri(Properties.Main.Default.tempDir + "\\" + sectionsDT.Rows[i][1].ToString());
}
}
}
}
Now here comes my problem: because the HTML page loaded in the webbrowser control is editable, each time I select a new item on the list (and before a new HTML file is loaded) a Save dialog appears (marked with 3 on the screenshot). I have my own code to save the changed HTML file, triggered by the "changing" event and it would be great if there would be somehow a solution to bypass, suppress, skip, or just simply hide this Save dialog, so the user won't need to click it every time he wants to go to another file. Here's the changing event:
private void sectionsTree_SelectedNodeChanging(object sender, RadTreeViewCancelEventArgs e)
{
Sections.fileCheck();
if (sectionsTree.SelectedNode != null)
{
emDataSet.dtSectionsDataTable sectionsDT = new emDataSet.dtSectionsDataTable();
sectionsDT.ReadXml(Properties.Main.Default.tempDir + "\\sections.xml");
for (int i = 0; i < sectionsDT.Rows.Count; i++)
{
if (sectionsTree.SelectedNode.Text == sectionsDT.Rows[i][2].ToString())
{
File.WriteAllText(Properties.Main.Default.tempDir + "\\" + sectionsDT.Rows[i][1].ToString(), htmlEditor.DocumentText);
}
}
}
}
My opinion is that the above codes are okay, and have nothing to do with my problem, because, my understanding is that the problem comes from a built-in feature of the WebBrowser control, however, just maybe, it could be a solution to intercept the WebBrowser control just before it checks if the file has been changed or not, and save it, so when it's checked it won't trigger the Save dialog, but I haven't figured out how to do that.
I'm looking forward to all your answers, and feel free to ask anything.
Thanks, Aemeth