I’d like to add a click handler for a button using jQuery, but the handler needs to reference data supplied by the controller. Is there a way to access ViewData in a script block in ASP.NET MVC? Or do I need to construct the script in the controller?
Share
If the script block is within the ASP.NET page then you can reference it…
e.g:
When the page is processed by the runtime engine, everything within the <% … %> blocks is evaluated, regardless of it’s location in the page.