How to get a register field element by name from html?

I am trying to make a registration program: For example: Button click1 event:

WebBrowser wb = new WebBrowser();
    wb.Navigate("register site");
    wb.Document.GetElementById("passwort").SetAttribute("value", textBox1.Text);
    wb.Document.GetElementById("register").InvokeMember("click");

Here is the html code of the registration page (from the view source):

<td><h5>Password:<br><input type="password" name="passwort"></td> 
<td> <input type="submit" name="register" value="Registri"></td>

Is there a chance to get an item by its name? because it does not have an identifier.

+3
source share
1 answer

You cannot access elements directly by name, but you can access it by first finding input tags and indexing the result to find tags by name.

wb.Document.GetElementsByTagName("input")["passwort"]

+3
source

All Articles