Saturday, 15 January 2011

visual studio 2008 - webbrowser control c# only invoke first time next time not working -



visual studio 2008 - webbrowser control c# only invoke first time next time not working -

i trying extract info website submitbutton invoke first time in document completed event.after loading first submitted page document completed event not executing code

private void b_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e) { webbrowser b = sender webbrowser; string response = ""; response = b.documenttext; htmlelement links = b.document.getelementbyid("btn1"); links.invokemember("click"); checktrafiicbuttonclick = true; messagebox.show(""); ***// upto these working , loading sec page after want fill info , want submit downwards line not working , should work after loading page submitted how can these*** htmlelement tfrno = b.document.getelementbyid("trfno"); tfrno.setattribute("value", "50012079"); htmlelement submitbuton = b.document.getelementbyid("submitbttn"); submitbuton.invokemember("click"); }

based on comment, code not work expected. after first click webbroser starts asynchronous page loading. should following:

private void b_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e) { webbrowser b = sender webbrowser; if(b.url.absoluteuri == "mydomain.com/page1.html") { string response = ""; response = b.documenttext; htmlelement links = b.document.getelementbyid("btn1"); links.invokemember("click"); checktrafiicbuttonclick = true; messagebox.show(""); return; } ***// upto these working , loading sec page after want fill info , want submit downwards line not working , should work after loading page submitted how can these*** if(b.url.absoluteuri == "mydomain.com//page2.htm") { htmlelement tfrno = b.document.getelementbyid("trfno"); tfrno.setattribute("value", "50012079"); htmlelement submitbuton = b.document.getelementbyid("submitbttn"); submitbuton.invokemember("click"); return; } }

also note, parts of page can loaded different source, illustration in iframe, have check proper uri

c# visual-studio-2008

No comments:

Post a Comment