Tag: navigateurl

在循环中触发WebBrowser.DocumentCompleted事件

我有一个简单的应用程序,我正在开发,需要遍历一个URL列表,这些URL传递给每个循环中的WebBrowsers Navigate函数。 我希望在每次调用Navigate函数后看到DocumentCompleted事件触发,但它似乎只是在整个表单完成加载后触发 – 这个循环已经完成。 我想我错过了一些基本的东西,但是一些帮助和建议会很棒! 谢谢! 这是我正在尝试的代码示例… 这个foreach循环运行在我正在使用的WinForms页面的Form Load事件中… int id = 0; foreach (DataRow row in quals.Rows) { URN = row[“LAIM_REF”].ToString(); string URN_formated = URN.Replace(“/”, “_”); string URL = “http://URL_I_AM_GOING_TOO/”; string FullURL = URL + URN_formated; wbrBrowser.ScriptErrorsSuppressed = true; wbrBrowser.Refresh(); wbrBrowser.Navigate(FullURL); id += 1; label1.Text = id.ToString(); } 在循环到达该行的位置: wbrBrowser.Navigate(FullURL); 我希望这个事件: private void […]

c#webbrowser控件不会导航到另一个页面

我有一个控制台应用程序,我已经在其中定义了一个webbrowser。 首先,我导航到一个页面并填写登录表单并调用提交按钮进行登录。 之后,我想使用相同的webbrowser转到同一站点中的另一个页面,但它不会导航到该页面。 相反,它导航到登录后重定向的页面。 这是我的澄清代码; 这段代码给了我www.websiteiwanttogo.com/default.aspx的源代码而不是product.aspx这里有什么问题? static WebBrowser wb = new WebBrowser(); [STAThread] static void Main(string[] args) { wb.AllowNavigation = true; wb.Navigate(“https://www.thewebsiteiwanttogo.com/login.aspx”); wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); Application.Run(); } static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (wb.Url.ToString().IndexOf(“login.aspx”) > -1) { wb.Document.GetElementById(“txtnumber”).SetAttribute(“value”, “000001”); wb.Document.GetElementById(“txtUserName”).SetAttribute(“value”, “myusername”); wb.Document.GetElementById(“txtPassword”).SetAttribute(“value”, “mypassword”); wb.Document.GetElementById(“btnLogin”).InvokeMember(“click”); } else { //wb.Document.Body you are logged in […]