-1

I would like to explain my scenary: I have a form that is composed by 2 other partial views.

The idea is the following

  1. The main Form show details about a Budget.

  2. The second show a form to send messages.

  3. The third show a form to send offer bids;

I would like that, when I do a Post in the 2nd ot 3rd form, the application return the main form. but, it is returning the form that was Posted.

It would work like I was using IFRAME... in other words, when I do a Post, it reflect only in the form that was Posted.

I am doing this form with MVC in C#.

Any tip?

I tried to use [ChildActionOnly], but I suppose that isn't what I am looking for.

enter image description here

Dan
  • 1,518
  • 5
  • 20
  • 48

2 Answers2

0

If I understand your problem correctly,you must use "return View("MainView");" instead "return View();"

  • but, how could I handle when the model isn't valid? For example, if the user miss to fill a field, then ModelState.AddModelError will be empty. How to handle that? – Dan Jul 31 '15 at 16:33
  • if you used RenderPartial() for render the 2nd , 3rd PartialView's ,modelstate is accessible .in those views. – Mohammad Reza Rahimi Jul 31 '15 at 16:40
  • 1
    if 2nd and 3rd form data do not exist in main model you must use the ajax request for send forms. – Mohammad Reza Rahimi Jul 31 '15 at 17:01
  • I'm trying to use Ajax request.. if it work properly, I give you as the right answer – Dan Jul 31 '15 at 17:10
0

The right Answer is:

  1. I created a new View;
  2. I changed the strucure Html.Beginform to Ajax.BeginForm;
  3. Used the jqueryunobtrusive.

You can see an example here: enter link description here

Community
  • 1
  • 1
Dan
  • 1,518
  • 5
  • 20
  • 48