Reputation: 13
I'm new with asp.net mvc.
How can I save the text of 3 input textboxes as one record concatenating them with asp.net mvc?
Thanks
HTML:
@Html.TextBox("txtNumber")
@Html.TextBox("txtMonth", null, new { maxlength = 2 })
@Html.TextBox("txtYear")
Controller:
public ActionResult AddUSA(FormCollection form) {
using (var db = new DatabaseImgRecEntities())
{
//db.Images.Add(new Image
}
return RedirectToAction("Index", "Home");
}
Upvotes: 1
Views: 1013
Reputation: 123739
Try this inside your action:-
var allValues =
string.Format("{0}{1}{2}",
form["txtNumber"],
form["txtMonth"],
form["txtYear"]);
Upvotes: 1