title: C# get element by name
body: <p>So I've figured out how to get an element by id, but I don't know how I can get an element by name.</p>
  <pre class="lang-cs prettyprint-override"><code>private void SendData()
  {
      webBrowser1.Document.GetElementById(&quot;textfield1&quot;)
          .SetAttribute(&quot;value&quot;, textBox1.Text);
      webBrowser1.Document.GetElementById(&quot;textfield2&quot;)
          .SetAttribute(&quot;value&quot;, textBox1.Text);
  }
  </code></pre>
  <p>The problem is in HTML <code>textfield1</code> is an id but <code>textfield2</code> is a name. So I want to figure out how to get <code>textfield2</code>:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
      &lt;input type=&quot;text&quot; id=&quot;textfield1&quot; value=&quot;TEXT1&quot;&gt;&lt;br&gt;
      &lt;input type=&quot;text&quot; name=&quot;textfield2&quot; value=&quot;TEXT2&quot;&gt;&lt;br&gt;
      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
  &lt;/html&gt;
  </code></pre>