Hi
How to open Partial View in Modal Popup on click of button.. Can we pass Action ("Delete") & Controller ("Location") thru variables
so that same Delete Partial View can be used whereever it is required.
Partial View
*************
@using (Html.BeginForm("Delete", "Location", FormMethod.Post))
{
}
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 6:44 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 1:22 AM EDT
step 1. Change the partial view as
create a common controller for common functionalities and return the partial view
public ActionResult getDeleteModal() { return PartialView("_DeletePartial"); }step 3. Call it using ajax and change the action attribute of form as
$.get("/Common/getDeleteModal",function(){ $('#deleteForm').attr('action', '/Location/Delete'); $("#deleteModal").modal('show') })Asma KhalidRank #160 · 14.7K reputationPosted Jun 21, 2021, 2:01 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 2:59 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 3:19 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 4:21 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 4:34 AM EDT
class
="modal-danger">Delete ConfirmationAre you sure you want to delete this record ?
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 5:09 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 6:04 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 21, 2021, 6:16 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 6:24 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 3:12 AM EDT
Delete Confirmation
Are you sure you want to delete this record ?
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 4:16 AM EDT
Hi
Now when i have put href="#" in anchor tag then it has gone in Js function. Modal popup has not opened yet
Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 4:30 AM EDT
Hi Sachin
AnyDiv was not defined . MOdal Poup is opening but when i click on Delete i gets below error
The required anti-forgery cookie "__RequestVerificationToken" is not present.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Mvc.HttpAntiForgeryException: The required anti-forgery cookie "__RequestVerificationToken" is not present.
In place of form tag can't we use @using (Html.BeginForm).
Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 21, 2021, 4:43 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts