That call is a bootstrap call.
You are noticing that the code is not shared between Views and so you don't get re-use.
It is a distinct challenge in this situation. The first (and easiest) way to get it working is to copy the modal dialog layout to both views. Obviously, that's not great though.
The real answer is to add the modal dialog to a
and then load that
. That way you have the code in one place but you can invoke the Modal from either one.
To add the Shared PartialView
In Visual Studio...
right-click the Views\Shared
folder and select "Add View..."
: Very important you put in in Shared folder so it can be found by all Views.
A Create View dialog will appear...
In that Create View dialog you will name the View (something like DialogView)
Here's a snapshot: https://i.stack.imgur.com/GQTtj.png
Notice that you have to select the checkbox that says, "Create as partial view".
It will create the view. You put your Bootstrap Modal dialog HTML in there.
Now, you can reference this PartialView in each of your pages to load it in the location where you want it to show up.
In each of the pages (CSHTML) where you want the modal dialog, use a line of Razor code (HTML Helper) like the following:
That simply makes sure the modal dialog will be in each page (View).
Now you use your normal Bootstrap call to make the modal pop-up.