HtmlElement.InvokeMember Method

Definition

Executes a method unique to the current element.

Overloads

InvokeMember(String, Object[])

Executes a function defined in the current HTML page by a scripting language.

InvokeMember(String)

Executes an unexposed method on the underlying DOM element of this element.

InvokeMember(String, Object[])

Source:
HtmlElement.cs
Source:
HtmlElement.cs
Source:
HtmlElement.cs

Executes a function defined in the current HTML page by a scripting language.

C#
public object InvokeMember(string methodName, params object[] parameter);
C#
public object? InvokeMember(string methodName, params object[]? parameter);

Parameters

methodName
String

The name of the property or method to invoke.

parameter
Object[]

A list of parameters to pass.

Returns

The element returned by the function, represented as an Object. If this Object is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface.

Examples

The following code example gets a TABLE called dataTable and uses the unexposed moveRow method to move a row from the end of the table to the beginning.

C#
private void ShiftRows(String tableName)
{
    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document;
        HtmlElementCollection elems = doc.All.GetElementsByName(tableName);
        if (elems != null && elems.Count > 0)
        {
            HtmlElement elem = elems[0];

            // Prepare the arguments.
            Object[] args = new Object[2];
            args[0] = (Object)"-1";
            args[1] = (Object)"0";

            elem.InvokeMember("moveRow", args);
        }
    }
}

Remarks

This method can be used to call methods from the Document Object Model (DOM) that do not have equivalents in managed code. All arguments supplied to InvokeMember will be converted to Win32 VARIANT data types before they are passed to the named scripting function.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

InvokeMember(String)

Source:
HtmlElement.cs
Source:
HtmlElement.cs
Source:
HtmlElement.cs

Executes an unexposed method on the underlying DOM element of this element.

C#
public object InvokeMember(string methodName);
C#
public object? InvokeMember(string methodName);

Parameters

methodName
String

The name of the property or method to invoke.

Returns

The element returned by this method, represented as an Object. If this Object is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface.

Remarks

This method can be used to call methods from the Document Object Model (DOM) that do not have equivalents in managed code. Use this version of InvokeMember to execute unexposed methods that take no arguments. For an example, see InvokeMember.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10