I made a textarea where I want people to be able to enter a comment. I then have a method in a controller that is supposed to use that string.
How do I pull the information from the textarea into the method?
I made a textarea where I want people to be able to enter a comment. I then have a method in a controller that is supposed to use that string.
How do I pull the information from the textarea into the method?
I don't know how your View or Action method looks like, but give your TextArea a name, like comment:
@using (Html.BeginForm("MyAction", "MyController")) {
@Html.TextArea("comment")
<input type="submit" value="Submit" />
}
And then make sure you have a parameter in your action with the same name:
[HttpPost]
public ActionResult MyAction(string comment)
{
// Do something with the comment
}
When you post, the default model binders will take care of putting the text from your TextArea into the comment parameter.