Hi
I want to define below code at only 1 place. Asof now i am writing it in each form
×
Cancel
DeleteThanks

Aman GuptaRank #193 · 12.4K reputationPosted Aug 23, 2024, 2:10 AM EDT
Hi Ramco,
To avoid duplicating the modal popup code in each form, you can centralize it in a single place and reuse it across your application. Here’s how you can do it:
1. Create a Partial View for the Modal:
You can create a partial view that contains the modal code. This partial view can be included in any page where you need the modal.
Steps:
Create Partial View:
Views/Sharedfolder (or any other folder) and selectAdd -> View._DeleteModal.cshtml.2. Include Partial View in Your Pages:
2. Alternative Using Layout or Master Page:
If you need this modal on many pages, you can add the modal code directly to your layout or master page, so it’s available throughout your application.
Steps:
Layout.cshtml(or master page if using WebForms).