We have several html pages which we are storing as resources within our project. We have a webbrowser control which displays the content. Our idea was that a user can use the anchor href links in the html pages to navigate between the other internal html pages.
Is this possible? Most of the content will be static and rather than have it downloaded each time from a web server we would prefer just to include it within the application. We also would prefer to keep it within the application and not extracted to keep it as portable as possible.
I see this, could this be adapted to our scenario?
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) {
// Redirect expertsexchange to stackoverflow
if (e.Url.ToString().Contains("experts-exchange")) {
e.Cancel = true;
webBrowser1.Navigate("http://stackoverflow.com");
}
}
If I assume this is possible for the moment then I would expect that either I would implement something like the above where it looks at the target URL or I would have to give each anchor element a name/uniqueID. I guess the first method would be easier to implement.
Thoughts?
Actually, my stupidity is the cause of my troubles. The code I show works beautifully but I had to set the navigating event of the webbrowser control to actually reflect soemthing. In short, I have two items, test.html and test2.html as included resources within the project and then I use…
if (e.Url.ToString().Contains("test2")){
e.Cancel = true;
webBrowser1.DocumentText = WindowsFormsApplication1.Properties.Resources.test2.ToString();
}