I have a script file, script.js
that holds all the javascript for a given page. In there, I do some ajax POST
methods and generate an HTML view from the response. There are certain buttons that I want to be shown if the current user is an admin / hidden if the current user is not an admin.
How can I add Razor syntax in success: function () {};
to display / hide those buttons?
You're looking for RazorJS.
Just wanted to add to SLaks' answer a few more details that made it hard for me to use RazorJS.
After installing it with the Package Manager as explained here, you should add in your razor view the following line:
@Html.RazorJSInclude("~/Scripts/my_javascript_file.js")
And then all your razor code will work just fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With