HtmlElementCollection.GetElementsByName(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of elements by their name.
public:
System::Windows::Forms::HtmlElementCollection ^ GetElementsByName(System::String ^ name);
public System.Windows.Forms.HtmlElementCollection GetElementsByName (string name);
member this.GetElementsByName : string -> System.Windows.Forms.HtmlElementCollection
Public Function GetElementsByName (name As String) As HtmlElementCollection
Parameters
- name
- String
The name or ID of the element.
Returns
An HtmlElementCollection containing the elements whose Name property match name
.
Examples
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"))
{
elem.InvokeMember("Submit");
}
}
}
}
Private Sub SubmitForm(ByVal FormName As String)
Dim Elems As HtmlElementCollection
Dim Elem As HtmlElement
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
Elems = .All.GetElementsByName(FormName)
If (Not Elems Is Nothing And Elems.Count > 0) Then
Elem = Elems(0)
If (Elem.TagName.Equals("FORM")) Then
Elem.InvokeMember("Submit")
End If
End If
End With
End If
End Sub
Remarks
While the Id property of an HtmlElement must be unique, multiple elements can use the same Name property.
Applies to
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示