Posts Tagged ‘.NET’

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 <br /> View: @ViewContext.Controller.ValueProvider.GetValue("action").RawValueController: @ViewContext.Controller.ValueProvider.GetValue("controller").RawValue <br /> View: @ViewContext.Controller.ValueProvider.GetValue("action").RawValue

Read more…

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) { <script src="~/Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script> }@if (false) { <script src="~/Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script> } Note: The if-statement prevents the script tag from being rendered into the html source code. Unfortunately, with the Razor view engine, there […]

Read more…

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 […]

Read more…