I can make the modal pop work even without passing controller but I need to set the model data since my modal suppose to be my create and update form.
Here is the button to call modal:
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_upload_image" >Upload Image </button>
<div class="modal fade" id="kt_modal_upload_image" tabindex="-1" aria-hidden="true">
.....
</div>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_upload_image" asp-controller="Image" asp-action="UpsertModal">
Upload Image</button>
[HttpGet]
public IActionResult UpsertModal(int? id)
{
.....
return View();
}
do you have any sample code to return PartialView from asp .net core Controller using metronic 8 .net core version? i need to populate the Model first before I display the modal. Please, Thank you
Hi,
Sorry for the late reply.
If you just want to return PartialView in your Controller then you can use the example below.
[HttpGet("/")]
public IActionResult Index()
{
return PartialView("~/Views/Partials/Modals/_UpgradePlan.cshtml");
}
Thank you so much for your response. My main issue is this code is not hitting the controller but it shows the modal.
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_upload_image" asp-controller="Image" asp-action="UpsertModal" asp-route->Upload Image </button>
I am using the the starter kit project in .net core 6
Hi,
You can toggle your modal from javascript code.
Firstly create modal instance.
var myModal = new bootstrap.Modal(document.getElementById("your modal id"), {
keyboard: false
})
myModal.show()
myModal.hide()
Hi.
Which app type are you currently working on? Angular, React, Laravel or etc.?
Regards