Get the value of an input type = text and play in a variable

1

I'm using ASP.Net-mvc4] in my C # project in Visual Studio and I need to get the value of input type=text that is in my view , and play in a variable in my controller , but not I figured I'd do it.

I would give the example I'm doing, but when I put html here it recognizes it as a command.

    
asked by anonymous 07.03.2014 / 20:40

2 answers

1

Two ways:

1. Passing the entire model to the Controller

[HttpPost]
public ActionResult AcaoDoController(MeuModel meuModel) { ... }

2. Passing Field name as Parameter

[HttpPost]
public ActionResult AcaoDoController(String fieldDoForm) { ... }

In CSHTML:

<input type="text" name="fieldDoForm" />
    
07.03.2014 / 20:44
0

The answer from @ cigano-morrison-mendez is correct, but you can also use a Helper: @Html.TextBox ("fieldDoForm")

    
07.03.2014 / 20:47