944,184 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1813
  • ASP.NET RSS
Nov 5th, 2009
-1

web browser's Browser_DocumentCompleted event is firing only first time,plz help

Expand Post »
Hi all,

I have a window service from which i am calling a windows application in c#.
and i am using web browser in window application to get html from a link,
but problem is that web browser's Browser_DocumentCompleted event is firing only first time when service calls application,only for the first page, it is not going on second page,not firing again,

but if we run the application alone it fires till the end of paging....working fine....

but i have to call it from service.
this is the code ---------
ASP.NET Syntax (Toggle Plain Text)
  1. public void myFunction()
  2. {
  3. System.Windows.Forms.WebBrowser Browser = new WebBrowser();
  4. clsErrorLog.WriteLog("goes for browser");
  5. Uri url = new Uri("my_url");
  6. Browser.Url = url;
  7. Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted);
  8. Browser.Visible = true;
  9. Browser.Size = new System.Drawing.Size(758, 539);
  10.  
  11. }
  12. --this is event
  13. private void Browser_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
  14. {
  15.  
  16. System.Windows.Forms.WebBrowser Browser = (System.Windows.Forms.WebBrowser)sender;
  17. this.Controls.Add(Browser);
  18.  
  19. HtmlDocument Doc;
  20. Doc = Browser.Document;
  21.  
  22. int LastPagerIndex = 0;
  23. Boolean ChkAltBtn = true;
  24. string AltPagerText = "";
  25.  
  26.  
  27. string ctlType = "";
  28. ctlType = "a";
  29. Boolean IsAnchor = true;
  30. if (IsAnchor)
  31. {
  32. if (ctlType.Trim().Length > 0)
  33. {
  34. HtmlElementCollection ctl = Doc.GetElementsByTagName(ctlType);
  35. if (ctl != null)
  36. {
  37. for (int i = 0; i < ctl.Count; i++)
  38. {
  39. if (ctl[i].InnerText != null)
  40. {
  41. if (ctl[i].InnerText.Trim() == (PagerBtnText - 2).ToString())
  42. {
  43. LastPagerIndex = i;
  44. }
  45.  
  46. if (ctl[i].InnerText.Trim() == PagerBtnText.ToString())
  47. {
  48.  
  49. ctl[i].InvokeMember("Click");
  50. ChkAltBtn = false;
  51. Browser.Show();
  52.  
  53. }
  54. }
  55. }
  56.  
  57. }
  58. }
  59. PagerBtnText++;
  60. }

Please help me....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ashu2409 is offline Offline
13 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: onmouseover / onmouseout advice
Next Thread in ASP.NET Forum Timeline: Retrieve EditItemTemplate controls of GridView at code-behind file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC