Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

multiple forms on one view in mvc

I'm using ASP.NET MVC 5, C#, Razor.

I have a view where i want to have 3 forms.


In each of those sections I would have some drop down lists and textboxes to collect the data.

So far I have only tried it using 1 form in my view and my page works fine.

But I was thinking of having 3 forms on the same view.
See I'm going to have each form in a div and I'm going to have some buttons control their visibility.  
So if i click button one the div holding form 1 is going to become unhidden while the other to are hidden and so on.

I'm new to mvc.
Before I tried doing it with my 3 forms all in the same view, I wanted to know if this is possible.

So the sections of my three forms would look something like the code below.
Is it possible to have 3 forms like the code shown below on one view?



@using(Html.BeginForm("Form1", "MyController", FormMethod.Post))
{

<input type="text" id="Form1LastName" />
<input type="text" id="Form1FirstName" />

   <input type="submit" name="Form1button" value="Create" />
}


@using(Html.BeginForm("Form2", "MyController", FormMethod.Post))
{

<input type="text" id="Form2LastName" />
<input type="text" id="Form2FirstName" />

   <input type="submit" name="Form2button" value="Create" />
}

@using(Html.BeginForm("Form3", "MyController", FormMethod.Post))
{


<input type="text" id="Form3LastName" />
<input type="text" id="Form3FirstName" />

   <input type="submit" name="Form3button" value="Create" />
}
ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial