We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the form control values in postback?

Platform: ASP.NET MVC |
Control: TimePicker |
Published Date: September 18, 2015 |
Last Revised Date: September 18, 2015

The list of form controls available in the Essential Studio are as follows:

  1. DatePicker.
  2. DateTimePicker.
  3. Numeric, Currency, and Percentage Textbox.
  4. Autocomplete and Dropdown list.
  5. Mask Edit.
  6. Checkbox and Radio Button.
  7. RichTextEditor.


The form control value can be obtained on the post back in the following ways.

By using,

  1. The Request object.
  2. The FormCollection object.
  3. The Parameters.
  4. The Scaffolding method.


The following sections explain how to get the values on the post back in these controls. You can create the EJ form controls, and define the form method as post and also define the respective action for the form post back. This is demonstrated in the following code example.




  1. Getting post back value by using Request object: In the Request object approach, you can use the request object of the HttpRequestBase class. The request object has the input field values in the name or value pairs. When you submit the form, the post method is called. You have six data, those in the Name or Value pairs, so that you can access these data in a POST Action method by passing the Name as an indexer in the Request object and get values from it. The following code example shows how to get the input fields values from the Request object.





Figure 1: Post back value using Request object


  1. Getting post back value by using the FormCollection object: You can also get the post requested data from the FormCollection object. The FormCollection object also has requested data in the name or value collection as the Request object. To get data from the FormCollection object, you need to pass it as a parameter, and it has all the input field data that submitted on the form. The following code example shows how to get the input fields values from the Form Collection.




Figure 2: Post back value using the FormCollection object

  1. Getting post back value by using the Parameters: You can pass all input field names as parameters to the post action method. The parameter name and input field name should be the same. These parameters have input field values that are entered to access the input field values from these parameters. The input field takes a string value from the end user, and so, the parameter should be a string type. There is no need to define a parameter in any specific sequence. The following code example shows how to get the input fields values from the parameters.



Figure 3: Post back value using Parameters


  1. Getting post back value by using Scaffolding method:

Strongly-Typed HTML Helper: The control supports strongly typed HTML helpers represented by lambda expressions that have model or template passed into the View. The Extension method is used to get a value from the model. The EditorFor takes lambda as a parameter that tells the helper with element of the model to use in the typed view. This enables the better compile-time checking of the views that allow you to find errors at build-time instead of at runtime, and also enables better code intelligence support within the view templates. The following steps explain how to get the values by using the Scaffolding methods.

1. Create the model for your requirement.


2. Create an action method that renders UI on the view page, and passes an empty model to be bound to the view page.


3. Create a strong typed view based on your model.


4. Create an action method, FormPost that handles the Post request and processes the data. In the action method, you can pass a model as the parameter. That model has UI input field data.


  1. Select the values from the EJ form controls and post the form. You can get the selected values in the post action from the model as follows.


Figure 4: Selected values in the post action



You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon