c# - Pause loop until WebBrowser navigates and loads the document -
I have a web page that takes me to a page containing student information on the search by student ID. I have a list of student IDs. I should retrieve the student's information from the second page and store it in a figure. Here is the code
string id {get; Set;} int lCount; & Lt; String & gt; ID = new list & lt; String & gt; {"A1201", "A1202", "A1203"}; Numeric result = new data (); Private void button1_Click (for object sender, EventArgs e) {for (I int = 0; I & lt; totalids; i ++) {lCount = I; Webbrowser1.Navigate ("http://www.sksit.com"); webbrowser1.DocumentCompleted + = new WebBrowserDocumentCompletedEventHandler (browser_DocumentCompleted)}} private void browser_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e) {if (e.URL.toString () == "http://www.sksit.com") {HtmlElement L = Webbrowser1.Document.GetElementById ("sid"); El.SetAttribute ("value", id [lCount]); HtmlElement cl = webbrowser1.Document.GetElementById ("search"); Cl.InvokeMember ("click on"); } Elseif (e.URL.toString () == "http://www.sksit.com/studentprofiles") {HtmlElement L = webbrowser1.Document.GetElementById ( "studentinfotab"); String information = el.InnerHtml; String [] tableinfo = info.Split (''); Datarov tro = result. Nudata (); For (int j = 0; j and lieutenant; colinfo.count (); j ++) {trow [ja] = tablefow [ja]; } result. Cry. Add (trow); }}
When I see the results table after execution, then there is no data in it. Having passed a code This code works fine when seen no data is put into a loop and it works to prevent 2. Please tell loop for the shows lCount until it completes loading and parsing Has throw some light on. Thank you. Do
Try to do something that is going to give you the idea of rough ..
string id {get; Set;} int lCount; & Lt; String & gt; ID = new list & lt; String & gt; {"A1201", "A1202", "A1203"}; Numeric result = new data (); Private Zero Button 1_Click (Object Sender, EventArgs e) {lCount = 0; Webbrowser1.Navigate ("http://www.sksit.com"); webbrowser1.DocumentCompleted + = new WebBrowserDocumentCompletedEventHandler (browser_DocumentCompleted)} private void browser_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e) {if (e.URL.toString () == "http://www.sksit.com") {HtmlElement L = webbrowser1 .Document.GetElementById ("sid"); El.SetAttribute ("value", id [lCount]); HtmlElement cl = webbrowser1.Document.GetElementById ("search"); Cl.InvokeMember ("click on"); } Elseif (e.URL.toString () == "http://www.sksit.com/studentprofiles") {HtmlElement L = webbrowser1.Document.GetElementById ( "studentinfotab"); String information = el.InnerHtml; String [] tableinfo = info.Split (''); Datarov tro = result. Nudata (); For (int j = 0; j and lieutenant; colinfo.count (); j ++) {trow [ja] = tablefow [ja]; } result. Cry. Add (trow); // It should be something like this (iCount & lt; id.kount) {iCount ++; Webbrowser1.Navigate ("http://www.sksit.com"); }}}
Comments
Post a Comment