I'm creating a WPF application that opens a WebBrowser instance and get the HTML code ... I was calling the elements by ID for example:
if the HTML is:
<input type="text" name="company" id="company" value=""/>
the C# code to add value to this element will be:
wb.Document.GetElementById("company").SetAttribute("value", String.Format("{0}", Company));
where wb is an instance of the WebBrowser Class
or if i have a button and need to click the Click event:
<input type="submit" id="button1" />
the C# code will be:
wb.Document.GetElementById("button1").InvokeMember("click");
now I have a problem is that I need to call the click function of a button that doesn't have an ID but just have a class name and value like the one below:
<input class="submit" type="submit" value="register"/>
how can i do this?
You have to use
GetElementByTagName("INPUT")
and then find yourHtmlElement
by itsGetAttribute("class")
method to invoke theclick
event.