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()).
Constructors
FormData()
public FormData()
FormData(HTMLFormElement, HTMLElement?)
The FormData() constructor creates a new FormData object.
public FormData(HTMLFormElement form = null, HTMLElement? submitter = null)
Parameters
formHTMLFormElementsubmitterHTMLElement
Remarks
Properties
this[int]
public string this[int i] { get; set; }
Parameters
iint
Property Value
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
Returns
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.
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
Returns
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.
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
namestring
Returns
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
namestring
Returns
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
namestring
Returns
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
namestring
Returns
- bool
trueif a key ofFormDatamatches the specifiedname. 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
Returns
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.
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
Returns
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.