Render MVC partial view inside bootstrap modal dialog

In this article, I am going to show you how to create a modal dialog using bootstrap and then load a MVC partial view in the dialog.

The steps are explained below with screenshots.

1. We need to have a modal container in the main layout page. All the dialogs will be loaded inside this container. I have hardcoded the styles for now. It is recommended that all the styles be put in a separate stylesheet file.

11

2. Now, we need to add the needed javascript. This script will make an internal Ajax call and will inject the content of the partial view inside the modal container div.

22

Continue reading

Advertisements