Hi
Can we create Dynamic Modal Popup . Currently i have defined on every form where required.
Thanks
Hi
Can we create Dynamic Modal Popup . Currently i have defined on every form where required.
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramco RamcoPosted Aug 23, 2024, 6:17 AM
Hi Aman
I have below User Control.How i can add your code here
Thanks
Aman GuptaPosted Aug 22, 2024, 5:05 PM
Hi Ramco,
Yes, you can create a dynamic modal popup that can be reused across different forms or pages, which will save you the hassle of defining it separately for each form. Here’s how you can achieve this in an ASP.NET WebForms application using JavaScript, jQuery, and a bit of C#.
Steps to Create a Dynamic Modal Popup:
Create a Reusable Modal Control in your Master Page or as a User Control:
Create a JavaScript Function to Show the Modal with Dynamic Content:
Trigger the Modal from Server-Side Code or Client-Side Events:
From Server-Side (C#):
From Client-Side (JavaScript):
Use the Modal Across Different Pages or Forms:
showModalfunction from either the client-side or the server-side. The content and behavior of the modal can be customized each time it is invoked.Benefits:
If you need the modal to perform specific actions (like submitting a form or making an AJAX call), you can include the logic in the
saveButtonHandlerparameter or in other custom event handlers.Jithu ThomasPosted Aug 22, 2024, 2:43 PM
Using Asp.net & Javascript: -
define a master page: -
Trigger the Modal with JavaScript
You can use JavaScript to dynamically load content into the modal and display it.
Now use the Modal in Your ASP.NET Pages
In any of your ASP.NET pages, you can now trigger this modal dynamically.
If you need to load the content of the modal dynamically (e.g., from a server-side script), you can use AJAX.
Trigger Example: