Skip to content
Advertisement

Razor Communicate Display of Modal from PageModel’s OnPost() Method

I want to communicate from my Razor PageModel’s OnPost() method to display the modal upon validation errors for it. Which basically means changing the modal’s css from display none to block. Is there a way for this to be done?

Currently on return Page() the modal is hidden because thats what its css is initially set to, and is normally displayed on the user clicking the button to show it. I marked in my PageModel code where Id like the communication to occur

JavaScript
JavaScript

Advertisement

Answer

You can try to use TempData.Here is a demo:

js:

JavaScript

handler:

JavaScript

result: enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement