Form ClassC# API
Represents an HTML form.
Inheritance Hierarchy

System Object
  Facilita.Web HtmlElement
    Facilita.Web Form

Namespace: Facilita.Web
Assembly: clrWebBrowser (in clrWebBrowser.dll) Version: 9.5.8.37 (1.0.0.0)
Syntax

public class Form : HtmlElement
Remarks

Each element in the form is represented by an HtmlElement object. The elements in the form are accessed by using the various "get" methods (e.g. GetHtmlElement(String), GetInputElement(String, String)). The HtmlElement objects can be modified to change the data that will be sent back to the server. More elements can be added to the form using AddElement(HtmlElement), and removed using RemoveElement(String, String).
Examples

The following example demonstrates the usual practice of obtaining a Form object by extracting it from a Response, using the ExtractForm(Int32) method.

The form is then usually modified by changing the HtmlElement objects it contains, and sent back to the server on a later request.

Response response = request.Send();
Form form = response.ExtractForm(0);
Examples

The following example demonstrates sending the Form as query data on a GET request.
// Create a Url with the form data as a query string
Url url1 = new Url("http://localhost/");
url1 = url1.WithQuery(form);

// Create a GET request based on the url and send it to the web server.
Request request1 = WebBrowser.CreateRequest(HttpMethod.GET, url1, 1);

// Send the request to the web server
Response response1 = request1.Send();
Examples

The following example demonstrates sending the Form as the message body on a POST request.
// Create a Url
Url url2 = new Url("http://localhost/");

// Create a POST request and set the form data as the message body
Request request2 = WebBrowser.CreateRequest(HttpMethod.POST, url2, 2);
request2.SetMessageBody(form);

// Send the the request to the web server
Response response2 = request2.Send();
See Also