Israel Thieme
Israel Thieme

Reputation: 13

How to save in asp.net mvc multiple input boxes text in one record

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

Answers (1)

PSL
PSL

Reputation: 123739

Try this inside your action:-

var allValues = 
    string.Format("{0}{1}{2}",
       form["txtNumber"],
       form["txtMonth"],
       form["txtYear"]);

Upvotes: 1

Related Questions