HtmlDocument::GetElementById Method (String^)
.NET Framework (current version)
Retrieves a single HtmlElement using the element's ID attribute as a search key.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- id
-
Type:
System::String^
The ID attribute of the element to retrieve.
Return Value
Type: System.Windows.Forms::HtmlElement^Returns the first object with the same ID attribute as the specified value, or null if the id cannot be found.
If there are multiple elements in the document with the same ID value, GetElementById will return the first one it finds.
The following code example retrieves a named TABLE from a document, counts up the number of rows, and displays the result in the Web page. The code example requires that you have a WebBrowser control in your project named WebBrowser1, and that you have loaded a Web page with a TABLE whose ID attribute is Table1.
.NET Framework
Available since 2.0
Available since 2.0
Show: