title: How to call a JavaScript method for a particular button event using C#
body: <p>I was given a task to automate the validation of content in a web page which has "from airport" and "to airport" text fields along with a <code>SearchFlights</code> button. After clicking on the <code>SearchFlights</code> button, I get the search results, and I need to compare these results with my expected values.</p>
  
  <p>I am using C# with HTML DOM programming to set the text in text fields and also to click on the <code>SearchFlights</code> button.</p>
  
  <p>Now, how do I capture the event (e.g. <code>documentcompleted</code>) and save those results so that I can compare them with the expected records? The button I have in that web apge looks like below:</p>
  
  <pre><code>&lt;a tabIndex="5" class="searchRht" id="searchBtn" onclick="sF();SearchFlights();return false;" href="" /&gt;
  </code></pre>
  
  <p>Once I click on the button, the page refreshes, and a message comes up, saying "loading the Flight Schedules," and after that it displays the results. It looks like the <code>onclick</code> method has two function calls: <code>sF()</code> and <code>SearchFlights()</code>.</p>
  
  <p>I am not sure how I can capture the events and the information returned by that web page.</p>
  
  <p>Below is the code used for clikcing on the button</p>
  
  <pre><code>doc = webBrowser1.Document;
  btnElem = doc.GetElementById(streleid);
  if (btnElem != null)
  {
      btnElem.RaiseEvent("onclick");//click on serach button
      btnElem.RaiseEvent("sF()"); //error comes here
      Application.DoEvents();  // this will load the browser document again
  }
  </code></pre>