Posts Tagged ‘MVC 3’

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…