System.Windows.Forms.HtmlElement Class

Represents an HTML element inside of a Web page.

See Also: HtmlElement Members

Syntax

public sealed class HtmlElement

Remarks

System.Windows.Forms.HtmlElement represents any possible type of element in an HTML document, such as BODY, TABLE, and FORM, among others. The class exposes the most common properties you can expect to find on all elements.

Most elements can have child elements: other HTML elements that are placed underneath them. Use the HtmlElement.CanHaveChildren property to test whether a given element has children, and the HtmlElement.Children collection to iterate through them. The HtmlElement.Parent property returns the System.Windows.Forms.HtmlElement in which the current element is nested.

You often need access to attributes, properties, and methods on the underlying element that are not directly exposed by System.Windows.Forms.HtmlElement, such as the SRC attribute on an IMG element or the Submit method on a FORM. The HtmlElement.GetAttribute(string) and HtmlElement.SetAttribute(string, string) methods enable you to retrieve and alter any attribute or property on a specific element, while HtmlElement.InvokeMember(string) provides access to any methods not exposed in the managed Document Object Model (DOM). If your application has unmanaged code permission, you can also access unexposed properties and methods with the HtmlElement.DomElement attribute.

Use the HtmlElement.TagName property to test whether an element is of a specific type.

Any HTML document can be modified at run time. You can create new System.Windows.Forms.HtmlElement objects with the HtmlDocument.CreateElement(string) method of System.Windows.Forms.HtmlDocument, and add them to another element using the HtmlElement.AppendChild(HtmlElement) or HtmlElement.InsertAdjacentElement(HtmlElementInsertionOrientation, HtmlElement) methods. You can also create the elements as HTML tags and assign them to an existing element's HtmlElement.InnerHtml property.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0