This documentation is archived and is not being maintained.

HtmlElementCollection.GetElementsByName Method

Gets a collection of elements by their name.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public HtmlElementCollection GetElementsByName (
	string name
public HtmlElementCollection GetElementsByName (
	String name
public function GetElementsByName (
	name : String
) : HtmlElementCollection
Not applicable.



The name or ID of the element.

Return Value

An HtmlElementCollection containing the elements whose Name property match name.

While the Id property of an HtmlElement must be unique, multiple elements can use the same Name property.

The following code example finds a FORM object using its name, and submits its data to the server programmatically. The code example requires that your application hosts a WebBrowser control named webBrowser1.

private void SubmitForm(String formName)
    HtmlElementCollection elems = null;
    HtmlElement elem = null;

    if (webBrowser1.Document != null)
        HtmlDocument doc = webBrowser1.Document;
        elems = doc.All.GetElementsByName(formName);
        if (elems != null && elems.Count > 0) 
            elem = elems[0];
            if (elem.TagName.Equals("FORM"))

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0