web browser submit button not invoking second time c# -


The button is trying to submit a webform practically on 1 click. In the first attempt i.e. after launching my web browser from Visual Studio, it automatically submits the form, but then clicking on button 1 loads the webpage, but the submit button is not used. While debugging its show, the line of code is executed but no action is taken Private Zero Button 1_Click (Object Sender, EventArgs e) {webBrowser1.Navigate ("xxxx"); WebBrowser1.DocumentCompleted + = webBrowser1_Document Complete; } Zero webBrowser1_DocumentCompleted (Object Sender, WebBrowserDocumentCompletedEventArgs e) {if (webBrowser1.Url.OriginalString.ToString () == "xxxx") {if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) {HtmlElementCollection doc = webBrowser1.Document.All; Leading (HtmlElement ele in doctor) {if (ele.GetAttribute ("name"). ToString () == "username") {ele.SetAttribute ("value", "xxxx"); } If (ele.GetAttribute ("name"). ToString () == "password") {ele.SetAttribute ("value", "xxxx"); } If (ele.GetAttribute ("classname") == "btn") {ele.InvokeMember ("click"); }}}} TextBox1.Text = webBrowser1.DocumentText; }

You want to set up only for DocumentCompleted event Once the web browser is pressed every time you press your code, keep adding it to the event series.

You want something like this (Pseudo code like I did not get VS):

  // When the form / guardian load once binds the event once. Public Zero Format () {webBrowser1.DocumentCompleted + = webBrowser1_DocumentCompleted; } // Simply navigate and the event will still be taking the Private Zero button 1_Click (Object Sender, EventArggs E) {webBrowser1.Navigate ("xxxx"); }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -