Search code examples
asp.net-mvctextboxsend

TextBox value + TextBox value send one value


How can I concenate two texboxes in MVC, so when you click submit it will send values from two textboxes.

For example

    <form method="get" action="@Url.Action("Index")">
        @(Html.TextBox("q", Model.Search.FreeSearch))
         ??? //i need here another textbox
        <input type="submit" value="Search"/> //when I click submit it will send values from both textboxess
    </form>

Thanks for any idea...


Solution

  • If you add another field ( textbox) in the model and then pass this field from the model, and create strongly typed view, then you can set two textboxes(fields) and send both value

    and in the controller you can concate both field values.

    e.g. model.firstname + model.lastname

    hope this idea helps you.