FormParameter Class
Binds the value of an HTTP request Form field to a parameter object.
Assembly: System.Web (in System.Web.dll)
| Name | Description | |
|---|---|---|
![]() | FormParameter() | Initializes a new unnamed instance of the FormParameter class. |
![]() | FormParameter(FormParameter) | Initializes a new instance of the FormParameter class with the values of the instance specified by the original parameter. |
![]() | FormParameter(String, DbType, String) | Initializes a new instance of the FormParameter class, using the specified string to identify which form variable field to bind to. |
![]() | FormParameter(String, String) | Initializes a new named instance of the FormParameter class, using the specified string to identify which form variable field to bind to. |
![]() | FormParameter(String, TypeCode, String) | Initializes a new named and strongly typed instance of the FormParameter class, using the specified string to identify which form variable to bind to. |
| Name | Description | |
|---|---|---|
![]() | ConvertEmptyStringToNull | Gets or sets a value indicating whether the value that the Parameter object is bound to should be converted to null if it is String.Empty.(Inherited from Parameter.) |
![]() | DbType | Gets or sets the database type of the parameter.(Inherited from Parameter.) |
![]() | DefaultValue | |
![]() | Direction | |
![]() | FormField | Gets or sets the name of the form variable that the parameter binds to. |
![]() | IsTrackingViewState | |
![]() | Name | Gets or sets the name of the parameter.(Inherited from Parameter.) |
![]() | Size | Gets or sets the size of the parameter.(Inherited from Parameter.) |
![]() | Type | Gets or sets the type of the parameter.(Inherited from Parameter.) |
![]() | ValidateInput | Gets or sets a value that indicates whether the client input in the parameter is validated. |
![]() | ViewState |
| Name | Description | |
|---|---|---|
![]() | Clone() | Returns a duplicate of the current FormParameter instance.(Overrides Parameter.Clone().) |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Evaluate(HttpContext, Control) | Updates and returns the value of the FormParameter object.(Overrides Parameter.Evaluate(HttpContext, Control).) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetDatabaseType() | |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | LoadViewState(Object) | Restores the data source view's previously saved view state.(Inherited from Parameter.) |
![]() | MemberwiseClone() | |
![]() | OnParameterChanged() | Calls the OnParametersChanged method of the ParameterCollection collection that contains the Parameter object.(Inherited from Parameter.) |
![]() | SaveViewState() | |
![]() | SetDirty() | |
![]() | ToString() | Converts the value of this instance to its equivalent string representation.(Inherited from Parameter.) |
![]() | TrackViewState() |
| Name | Description | |
|---|---|---|
![]() ![]() | ICloneable.Clone() | |
![]() ![]() | IStateManager.LoadViewState(Object) | This API supports the product infrastructure and is not intended to be used directly from your code. Restores the data source view's previously saved view state.(Inherited from Parameter.) |
![]() ![]() | IStateManager.SaveViewState() | |
![]() ![]() | IStateManager.TrackViewState() | |
![]() ![]() | IStateManager.IsTrackingViewState |
You can use the FormParameter class to bind the value of a form variable in the Form collection to a parameter used in a parameterized query or command. Controls that bind data to the parameter might throw an exception if a FormParameter is specified but no corresponding form variable is passed. They might also display no data if the form variable is passed with no corresponding value. Set the DefaultValue to avoid these situations where appropriate.
The FormParameter class provides the FormField property, which identifies the name of the form variable to bind to, in addition to those inherited from the Parameter class.
Important |
|---|
The FormParameter does not validate the value passed by the form element in any way; it uses the raw value. In most cases you can validate the value of the FormParameter before it is used by a data source control by handling an event, such as the Selecting, Updating, Inserting, or Deleting event exposed by the data source control you are using. If the value of the parameter does not pass your validation tests, you can cancel the data operation by setting the Cancel property of the associated CancelEventArgs class to true. |
The following code example demonstrates how to insert data into a database using the SqlDataSource control and a simple ASP.NET Web page. The current data in the data table is displayed in the DropDownList control. You can add new records by entering values in the TextBox controls and clicking the button. When the button is clicked, the specified values are inserted into the database, and the DropDownList is refreshed.
Security Note
|
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.








