I want to load the content from one page into a modal on another page on the click of a button, but it is also loading in the content from the __Layout page. I have tried calling a controller using:
JavaScript
x
7
1
$('.btn').click(function(){
2
$('.container').load('/Home/MyPage');
3
})
4
5
6
<div class="container"></div>
7
However, I cannot get it to load in solely what is in the MyPage.cshtml file. What am I doing wrong? Any help would be great, thanks.
Advertisement
Answer
Add the below snippet on top of MyPage.cshtml
to avoid loading with the layout page.
JavaScript
1
4
1
@{
2
Layout = null;
3
}
4