1

I'm fairly new to MVC and Bootstrap and looking for some advice on what I imagine is a fairly simple scenario...

I've got two models:

  • Person
  • PersonDetails

The two models share a common primary/foreign key reference (PersonID)

The view for Person simply renders a list of names:

  • John
  • Tom
  • Michael

What I'm looking to do is render a modal pop-up when someone clicks on one of these names, and display the corresponding data from PersonDetails (based on the common PersonID relationship).

I've got the simple views working, as well as a quick example modal pop-up. What I'm having trouble with at the moment is how to go about getting the PersonDetails data into the modal pop-up.

Can someone give me some pointers as to how I should best go about achieving this? As I mentioned I'm fairly new to MVC/Bootstrap so any information would be much appreciated.

Hysteria86
  • 367
  • 1
  • 10

1 Answers1

0

I would use a partial view to store the modal header, body and footer and pass the person name (or ID) to the controller using an AJAX call, returning a PartialView, which will will be placed in your modal div on success.

This SO answer explains it pretty well: https://stackoverflow.com/a/16011752/3105807

Community
  • 1
  • 1
Amy Barrett
  • 564
  • 3
  • 14
  • 27
  • Thanks for the answer. In people's experience is it better to achieve this functionality via AJAX or using the Bootstrap library? Finding a mixture of opinions during research. – Hysteria86 Mar 08 '16 at 09:17