Hello, I'm working on an application that uses an AxWebBrowser control. I've had a couple of problems. I dynamically create the HTML that I load into some of the pages and others are static pages. Sometimes when I click on a link that should take be to a dynamic page I get a "Page cannot be found" page instead. Then I click back and click on the link again and it works fine. It seems to be a timing issue, but I can't quite figure it out. Basically my code to create the page dynamically looks like this:
//********** IHTMLDocument2 HTMLDocument = null; HTMLDocument = (IHTMLDocument2)webMain.Document; HTMLDocument.clear(); HTMLDocument.write(h); HTMLDocument.close(); Thread.Sleep(250); HookingEvents(); //********** h is a string that is created in some other functions. HookingEvents loops through document and creates the events for when someone clicks on a link. //********* public void HookingEvents() { IHTMLDocument2 doc; object boxDoc = this.webMain.Document; doc = (IHTMLDocument2)boxDoc; if (doc != null ) { IHTMLElementCollection allElems = doc.all; if ( allElems == null ) return; int len = allElems.length; // DocComplete fires multiple times, check that we have elements. if ( len < 1) return; for ( int i = 0; i< len; i++) { object boxe = allElems.item(i,i); IHTMLElement elem = (IHTMLElement)boxe ; string tagName = elem.tagName.ToUpper(); if ( tagName == "A" ) { mshtml.HTMLAnchorEvents2_Event aevent = (mshtml.HTMLAnchorEvents2_Event) boxe; aevent.onclick += new mshtml.HTMLAnchorEvents2_onclickEventHandler(OnAnchorClick); } } } } //******************* OnAnchorClick calls the code above that writes the document. Does anyone have any thoughts about this? I'm a complete loss for what to do. One other issue is that my app seems to use a lot of memory. When I look in the task manager it will be using 100MB and still growing. It seems like it's still storing each page in memory as I browse. I hope this makes sense. Thank you very much for any help, I really appreciate it. Thanks, Nick =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com