-
ASP.NET MVC 3: How to get the current controller and action in a Razor view
The following code snippet enables you to access the name of the controller and the action that are processing the (current) request: Controller: @ViewContext.Controller.ValueProvider.GetValue(“controller”).RawValue View: @ViewContext.Controller.ValueProvider.GetValue(“action”).RawValue
-
Microsoft Visual Studio & ASP.NET MVC 3: Add jQuery IntelliSense support for Razor pages
To enable Visual Studio’s IntelliSense support for jQuery on Razor pages just add the following code line to your view: @if (false) { } Note: The if-statement prevents the script tag from being rendered into the html source code. Unfortunately, with the Razor view engine, there is no central place to add the reference to […]
-
ASP.NET: Programmatically adding <script> tags to include JavaScript files in the master page’s <head> tag
One common task of ASP.NET master pages is the definition of the page’s <head> tag, which could include <script> tags to include external JavaScript files>. If you do not use absolute paths to refer to the JavaScript file, adding a <script> leads to the problem, that the path to the JavaScript file has to consider […]