5
Reply

Can we have multiple forms in a View in ASP.NET MVC

Anupam Singh

Anupam Singh

Jun 13, 2014
16.1k
1

    Yes we can, here is an example :// submit first form @using(BeginForm("Action","Controller",FormMethod.Post)) {@TextBox("txtBox1")}//submit second form @using(BeginForm("Action","Controller",FormMethod.Post)) {@TextBox("txtBox2")}

    Anupam Singh
    July 01, 2014
    3

    you can have multiple forms in single View just give different View to each form But if you want to use Single View then it is change to have to check from which foam the submit button is clicked Simple by send Submit button name

    Ali Sadaam
    February 27, 2015
    0

    Yes we can have any number of forms in any HTML or web page.

    Ritesh Sharma
    July 26, 2014
    0

    @model ViewModel@using (Html.BeginForm("Login", "ABCController", FormMethod.Post, new {})) {@Html.LabelFor(m => m.LoginUsername)@Html.TextBoxFor(m => m.LoginUsername)@Html.LabelFor(m => m.LoginPassword)@Html.TextBoxFor(m => m.LoginPassword)}@using (Html.BeginForm("UserRegister", "ABCController", FormMethod.Post, new {})) {@Html.LabelFor(m => m.RegisterFirstName)@Html.TextBoxFor(m => m.RegisterFirstName)@Html.LabelFor(m => m.RegisterLastName)@Html.TextBoxFor(m => m.RegisterLastName)@Html.LabelFor(m => m.RegisterUsername)@Html.TextBoxFor(m => m.RegisterUsername)@Html.LabelFor(m => m.RegisterPassword)@Html.TextBoxFor(m => m.RegisterPassword)In Controller you can Give a code Below[HttpPost] public ActionResult Login(ViewModel model) {//do your login code here }[HttpPost] public ActionResult UserRegister(ViewModel model) {//do your registration code here }

    Jagan Mohan
    July 16, 2014
    0

    It is not Possible having multiple view in same page in MVC

    Yogesh Tyagi
    July 04, 2014
    0