Interviews - C# Corner

Anupam Singh
Can we have multiple forms in a View in ASP.NET MVC
By Anupam Singh in ASP.NET MVC onJun 13 2014
  • Anupam Singh
    Jul, 2014 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")}

    • 3
  • Ali Sadaam
    Feb, 2015 27

    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

    • 0
  • Ritesh Sharma
    Jul, 2014 26

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

    • 0
  • Jagan Mohan
    Jul, 2014 16

    @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 }

    • 0
  • Yogesh  Tyagi
    Jul, 2014 4

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

    • 0

Most Popular Companies

Most Popular Job Functions