.NET Framework Class Library
HtmlElement.InvokeMember Method (String, Object[])
Executes a function defined in the current HTML page by a scripting language.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Syntax
Visual Basic
Public Function InvokeMember ( _ methodName As String, _ ParamArray parameter As Object() _ ) As Object
C#
public Object InvokeMember( string methodName, params Object[] parameter )
Visual C++
public:
Object^ InvokeMember(
String^ methodName,
... array<Object^>^ parameter
)
F#
member InvokeMember : methodName:string * parameter:Object[] -> Object
Parameters
- methodName
- Type: System.String
The name of the property or method to invoke.
- parameter
- Type: System.Object[]
A list of parameters to pass.
Return Value
Type: System.ObjectThe 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.
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.
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.
Visual Basic
Private Sub ShiftRows(ByVal TableName As String) If (WebBrowser1.Document IsNot Nothing) Then With WebBrowser1.Document Dim Elems As HtmlElementCollection = .All.GetElementsByName(TableName) If (Not Elems Is Nothing And Elems.Count > 0) Then Dim Elem As HtmlElement = Elems(0) ' Prepare the arguments. Dim Args(2) As Object Args(0) = CObj("-1") Args(1) = CObj("0") Elem.InvokeMember("moveRow", Args) End If End With End If End Sub
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); } } }
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also