1

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");
}

1 Answer 1

1

Try this inside your action:-

var allValues = 
    string.Format("{0}{1}{2}",
       form["txtNumber"],
       form["txtMonth"],
       form["txtYear"]);
Sign up to request clarification or add additional context in comments.

Comments

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.