HtmlSelectElement Class

https://html.spec.whatwg.org/multipage/form-elements.html#htmlselectelement

public sealed class HtmlSelectElement : HtmlElement
Inheritance
HtmlElement HtmlSelectElement

Properties

NameDescription
AutocompleteGets or sets the value of the autocomplete content attribute.
DisabledGets or sets a value indicating whether the element has the disabled content attribute.
FormGets the form owner of the element, or null when it has none.
LabelsGets the label elements associated with the element.
LengthGets or sets the number of options; setting it adds blank options or removes the last ones.
MultipleGets or sets a value indicating whether the element has the multiple content attribute.
NameGets or sets the value of the name content attribute.
OptionsGets the collection of the options of the select element.
RequiredGets or sets a value indicating whether the element has the required content attribute.
SelectedIndexhttps://html.spec.whatwg.org/multipage/form-elements.html#dom-select-selectedindex
SelectedOptionsGets the collection of the options that are currently selected.
SizeGets or sets the value of the size content attribute.
Typehttps://html.spec.whatwg.org/multipage/form-elements.html#dom-select-type
ValidationMessageGets the error message that would be shown to the user if the element is invalid, or an empty string.
ValidityGets the ValidityState object that describes the validity of the element.
Valuehttps://html.spec.whatwg.org/multipage/form-elements.html#dom-select-value
WillValidateGets a value indicating whether the element is a candidate for constraint validation.

Autocomplete

HtmlElements.g.cs

Gets or sets the value of the autocomplete content attribute.

public string Autocomplete { get; set; }

Gets or sets a value indicating whether the element has the disabled content attribute.

public bool Disabled { get; set; }

Gets the form owner of the element, or null when it has none.

public HtmlFormElement? Form { get; }

Gets the label elements associated with the element.

public NodeList Labels { get; }

Gets or sets the number of options; setting it adds blank options or removes the last ones.

public uint Length { get; set; }

Gets or sets a value indicating whether the element has the multiple content attribute.

public bool Multiple { get; set; }

Gets or sets the value of the name content attribute.

public string Name { get; set; }

Gets the collection of the options of the select element.

public HtmlOptionsCollection Options { get; }

Gets or sets a value indicating whether the element has the required content attribute.

public bool Required { get; set; }

SelectedIndex

SelectElements.cs

https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-selectedindex

public int SelectedIndex { get; set; }

SelectedOptions

SelectElements.cs

Gets the collection of the options that are currently selected.

public HtmlCollection SelectedOptions { get; }

Gets or sets the value of the size content attribute.

public uint Size { get; set; }

https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-type

public string Type { get; }

ValidationMessage

FormControlMembers.cs

Gets the error message that would be shown to the user if the element is invalid, or an empty string.

public string ValidationMessage { get; }

Gets the ValidityState object that describes the validity of the element.

public ValidityState Validity { get; }

https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-value

public string Value { get; set; }

Gets a value indicating whether the element is a candidate for constraint validation.

public bool WillValidate { get; }

Indexers

NameDescription
this[uint]Gets or sets the option at the given index; setting null removes the option.

Gets or sets the option at the given index; setting null removes the option.

public HtmlOptionElement? this[uint index] { get; set; }

Methods

NameDescription
Add(HtmlElement, HtmlElement?)Inserts an option or optgroup element before the given element, or at the end when no element is given.
Add(HtmlElement, int)Inserts an option or optgroup element before the option at the given index, or at the end when the index is invalid.
CheckValidity()Returns whether the element satisfies its constraints, firing an invalid event when it does not.
Item(uint)Returns the option at the given index, or null when the index is out of range.
NamedItem(string)Returns the first option whose id or name matches the given name, or null when none matches.
Remove(int)https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-remove
ReportValidity()Checks whether the element satisfies its constraints, firing an invalid event when it does not.
SetCustomValidity(string)Sets the custom validity error message of the element; an empty string clears the custom error.
ShowPicker()https://html.spec.whatwg.org/multipage/input.html#dom-select-showpicker

Add overloads

Add(HtmlElement, HtmlElement?)

SelectElements.cs

Inserts an option or optgroup element before the given element, or at the end when no element is given.

public void Add(HtmlElement element, HtmlElement? before = null)

Add(HtmlElement, int)

SelectElements.cs

Inserts an option or optgroup element before the option at the given index, or at the end when the index is invalid.

public void Add(HtmlElement element, int before)

CheckValidity()

FormControlMembers.cs

Returns whether the element satisfies its constraints, firing an invalid event when it does not.

public bool CheckValidity()

Returns the option at the given index, or null when the index is out of range.

public HtmlOptionElement? Item(uint index)

NamedItem(string)

SelectElements.cs

Returns the first option whose id or name matches the given name, or null when none matches.

public HtmlOptionElement? NamedItem(string name)

https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-remove

public void Remove(int index)

ReportValidity()

FormControlMembers.cs

Checks whether the element satisfies its constraints, firing an invalid event when it does not.

public bool ReportValidity()

SetCustomValidity(string)

FormControlMembers.cs

Sets the custom validity error message of the element; an empty string clears the custom error.

public void SetCustomValidity(string error)

ShowPicker()

SelectElements.cs

https://html.spec.whatwg.org/multipage/input.html#dom-select-showpicker

public void ShowPicker()