0

I have a problem to get a value of textbox which is in view into the controller.

In WebForms it was quite easy, it needed just to call textbox in codebehind trouhg Id, but in MVC it seems not possible this way, or?

Help me please!

Take care, Ragims

1 Answer 1

6

You need to post the form data back to the controller... when this happens, it attempts to map a property value handling the action method and auto assign it. So if you have:

<input type="text" id="T1" name="T1" />

In a form post, it will post to action method:

public ActionResult Process(string T1)

Or you can use a FormCollection instead

public ActionResult Process(FormCollection form)

Which contains all of the values posted back.

But you have to post back, either via a form and clicking a submit button (only what's in the form gets posted) or by using a JS library to post the form (like JQuery).

2
  • +1 They could also use Request.Form["T1"]. Just thought I'd ad that. Commented Aug 19, 2010 at 16:19
  • thank you brian, you helped me to find right direction to solve my problem. great help from you, thanks again!
    – r.r
    Commented Aug 19, 2010 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.