views:

647

answers:

1

I have a webbrowser control in C#.NET CF.

When the user clicks on a hyperlink, instead of attempting to navigate to the specified URL how would I instead display a fragment of html content stored in memory?

I've tried the following

//page doesnt refresh
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
    if (e.Url.Host != String.Empty) {
       e.Cancel = true;
       webBrowser.DocumentText = "<html> some text </html>";
    }
}

//some text appears but then the original page is loaded up
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
    if (e.Url.Host != String.Empty) {
       webBrowser.DocumentText = "<html> some text </html>";
    }
}
+1  A: 

I would suggest trying to use webBrowser.Stop() in conjunction with the Cancel event, which will then completely halt the navigation.

Kyle Rozendo