[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

jaroslaw.pawlak

6/23/2008 1:54:00 PM

Hello, I'm trying to automate webbrowser using webbrowser control.
I have problem with pages using ajax, as when LoadComplete event is
executed, ajax part is not yet loaded, and after it is loaded -
webbrowser does not throw next complete event. How should I use
webbrowser control in order to get document with dom uptated with the
ajax part?.
Thanks in advance for any ideas
Jarek
2 Answers

Bim Jeam

7/15/2008 5:00:00 AM

0

Don't know if this is exactly what you're after but (providing I know the
target's ID or some other characteristic) I do it like this ...



// Get the target



(e.g)



HtmlElement target =
_webBrowser.Document.GetElementById("somedivthatwillbepopulatedbytheajaxrequest");



if (target != null)

{

target.AttachEventHandler("onpropertychange", new EventHandler(handler));

}



The event will fire whenever the element is (re)populated with HTML so all
you do is implement the handler so you can check the InnerHTML or InnerText
or whatever it is you need to do, and do it to your hearts content



(e.g)



private void handler(Object sender, EventArgs e)

{

HtmlElement div =
_webBrowser.Document.GetElementById("somedivthatwillbepopulatedbytheajaxrequest");

if (div == null) return;

String x = div.InnerHtml; // etc

if (!x.Equals("Loading...", StringComparison.InvariantCultureIgnoreCase))

{

// Now the element has been populated, do something

}

}





"jaroslaw.pawlak@gmail.com" wrote:

> Hello, I'm trying to automate webbrowser using webbrowser control.
> I have problem with pages using ajax, as when LoadComplete event is
> executed, ajax part is not yet loaded, and after it is loaded -
> webbrowser does not throw next complete event. How should I use
> webbrowser control in order to get document with dom uptated with the
> ajax part?.
> Thanks in advance for any ideas
> Jarek
>

jaroslaw.pawlak

7/22/2008 6:35:00 AM

0

Hi, this is exactly what I need. Works fine. Thanks!