How to Retrieve form values in controller action?

Total Post:45

Points:323
C#
 411  View(s)
Ratings:
Rate this:

I want to get form textbox data .I have an MVC controller that has this Action Method:

[HttpPost]

public ActionResult SubmitAction()
{
     // Get Post Params Here
 ... return something ...
}

and i have simple form with textboxes

How I access the parameter values?

  1. Post:52

    Points:366
    Re: How to Retrieve form values in controller action?

    You could have your controller action take an object which would reflect the form input names ..

    [HttpPost]
    
    public ActionResult SubmitAction()

        var value1 = Request["SimpleProp1"];
        var value2 = Request["SimpleProp2"];
        var value3 = Request["ComplexProp1.SimpleProp1"];
        ...
        ... return something ...
    }



Answer