Table of Contents

Class FormData

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The FormData interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the Windowfetch, Send(Union236?) or SendBeacon(string, Union41?) methods. It uses the same format a form would use if the encoding type were set to "multipart/form-data".

[Value("FormData")]
public class FormData
Inheritance
FormData
Inherited Members

Remarks

You can also pass it directly to the URLSearchParams constructor if you want to generate query parameters in the way a {{HTMLElement("form")}} would do if it were using simple GET submission.

An object implementing FormData can directly be used in a {{jsxref("Statements/for...of", "for...of")}} structure, instead of 'FormData.Entries': for (const p of myFormData) is equivalent to for (const p of myFormData.entries()).

-Using FormData objects
-Form

See also on MDN

Constructors

FormData()

public FormData()

FormData(HTMLFormElement, HTMLElement?)

The FormData() constructor creates a new FormData object.

public FormData(HTMLFormElement form = null, HTMLElement? submitter = null)

Parameters

form HTMLFormElement
submitter HTMLElement

Remarks

Properties

this[int]

public string this[int i] { get; set; }

Parameters

i int

Property Value

string

Methods

Append(string, Blob, string)

The append() method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

[Value("append")]
public GlobalObject.Undefined Append(string name, Blob blobValue, string filename = null)

Parameters

name string
blobValue Blob
filename string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The difference between Set(string, string) and append() is that if the specified key already exists, set() will overwrite all existing values with the new one, whereas append() will append the new value onto the end of the existing set of values.

-Using FormData objects
-Form

See also on MDN

Append(string, string)

The append() method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

[Value("append")]
public GlobalObject.Undefined Append(string name, string value)

Parameters

name string
value string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The difference between Set(string, string) and append() is that if the specified key already exists, set() will overwrite all existing values with the new one, whereas append() will append the new value onto the end of the existing set of values.

-Using FormData objects
-Form

See also on MDN

Delete(string)

The delete() method of the FormData interface deletes a key and its value(s) from a FormData object.

[Value("delete")]
public GlobalObject.Undefined Delete(string name)

Parameters

name string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Get(string)

The get() method of the FormData interface
returns the first value associated with a given key from within a FormData
object. If you expect multiple values and want all of them, use the
GetAll(string) method instead.

[Value("get")]
public Union237? Get(string name)

Parameters

name string

Returns

Union237?

A value whose key matches the specified name. Otherwise, null.

Remarks

GetAll(string)

The getAll() method of the FormData interface returns all the values associated with a given key from within a FormData object.

[Value("getAll")]
public List<Union237> GetAll(string name)

Parameters

name string

Returns

List<Union237>

An array of values whose key matches the specified name. Otherwise, an empty list.

Remarks

Has(string)

The has() method of the FormData interface returns whether a FormData object contains a certain key.

[Value("has")]
public bool Has(string name)

Parameters

name string

Returns

bool

true if a key of FormData matches the specified name. Otherwise, false.

Remarks

Set(string, Blob, string)

The set() method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.

[Value("set")]
public GlobalObject.Undefined Set(string name, Blob blobValue, string filename = null)

Parameters

name string
blobValue Blob
filename string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The difference between set() and Append(string, string) is that if the specified key does already exist, set() will overwrite all existing values with the new one, whereas append() will append the new value onto the end of the existing set of values.

-Using FormData objects
-Form

See also on MDN

Set(string, string)

The set() method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.

[Value("set")]
public GlobalObject.Undefined Set(string name, string value)

Parameters

name string
value string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The difference between set() and Append(string, string) is that if the specified key does already exist, set() will overwrite all existing values with the new one, whereas append() will append the new value onto the end of the existing set of values.

-Using FormData objects
-Form

See also on MDN