Reputation: 137
I need to create a partial view for a calendar and it's not showing up I don't know why. I try to display the partial view with:
<div>
@{
await Html.RenderPartialAsync("_Calendar");
}
I don't know what the problem is...If I made a button in my navigation bar with:
<a class="nav-link text-dark" asp-area="" asp-controller="Booking" asp-action="Calendar">Calendar</a>
and then in the BookingController simply do this:
public class BookingController : Controller
{
public IActionResult Index()
{
return View();
}
public ActionResult Calendar()
{
return View("_Calendar");
}
}
There it shows up..but not in the Booking Index like it should. Here are some images:
The red rectangle is where I want the _Calendar to be. This Image if what shows if I go to _Calendar using the nav bar:
The _Calendar partial view is in my shared folder. Let me know if you need any more information.
So I added a
Upvotes: 0
Views: 1111
Reputation: 18139
If you have js code in _Calendar,the page which refernces _Calendar will not load the js code.And you need to put the js code of _Calendar into the page which refernces _Calendar. Here is a demo worked. Main.cshtml(reference a partial view):
@{
ViewData["Title"] = "Main";
}
<h1>Main</h1>
<div style="height:400px;width:400px;border:1px solid red;">
<partial name="_partial1" />
</div>
@section scripts{
<script type="text/javascript">
$("#div1").text("Hello World!");
</script>
}
_partial1.cshtml(in Shared folder):
<div id="div1">
</div>
result:
Upvotes: 1