razor

asp.net mvc3 razor documentation?

Is there any documentation on how to use Razor view engine using asp.net mvc3? or any other resources? Trying to find it in google and msdn with no luck so far. ...

Razor/CSHTML - Any Benefit over what we have?

Hello, Anyone out there using the new CSHTML pages feature and is finding that they prefer this new view engine syntax over the existing ASP.NET MVC default view engine or over web forms, and if so, why? What about CSHTML gives you an advantage over MVC or web forms, or vice versa? Just curious to hear people's take on it. Thanks. ...

Can Razor be used with visual studio 2008?

Scott Gu didn't talk about this in his blog post. Will there be intellisense support for razor on vs 2008? MS is giving everyone a hard time by releasing major upgrades so frequently :D ...

HtmlHelper NameFor method

Is there any Html.NameFor feature already implemented, that get the name html attribute for a model item? I'l like to use the following code in my Razor view: <input type="text" value="@Model.User.Email" name="@Html.NameFor(x => x.User.Email)"> ...

Pointers for writing a unit test for a Razor based View needed.

I'm trying out the new Razor view engine with MVC 3 Preview 1 and would really like to write a simple unit test using NUnit/Moq. I haven't seen any examples of this actually being done yet - despite it being one of the real selling features on Razor. So, if I have a Controller, that uses a DBConext object (EF4 CTP code first) and the vi...

Is Razor view with ASPX .Master page possible?

Is it possible to keep my existing .master page and have it used with a new ASP.NET MVC 3 Razor view? I tried this: @{ LayoutPage = "~/Views/Shared/Site.master"; } And it gives me this error message: The file '~/Views/Shared/Site.master' could not be rendered, because it does not exist or is not a valid page. ...

How to get IntelliSense for Razor View Engine

Hi, Just installed Microsoft Visual Web Developer 2010 and trying to create an MVC application with Razor View Engine. When opened a ".cshtml" file, I am not able to get colors for syntaxes in editor and also intellisense is not appearing. Is there any option I explicitly need to enable it? ...

SQL to Insert data into multiple tables from one POST in WebMatrix Razor Syntax

I've got two form fields from which the user submits a 'category' and an 'item'. The following code inserts the category fine (I modified it from the WebMatrix intro PDF) but I've no idea how to then insert the 'item' into the Items table. I'll also need to add the Id of the new category to the new item row. This is the code that's wor...

Razor Compilation Error

I have the following section of Razor code and it fails during runtime with a compilation error: @foreach(var stat in Model){ <li> @stat.EffectiveDate.ToShortDateString() - @stat.EventType.Description <br /> TimeTaken: @if (@stat.TimeTaken.Hours > 0) { @sta...

ASP.NET MVC 2/.NET 4/Razor - Can't use Any() extension method on a ViewModel member

I'm trying out the Razor ViewEngine from ASP.NET MVC 3 Preview 1 and I'm running into an issue trying to using the Any() extension method. Here's the code I use to set the property in the controller: ViewModel.Comparisons = DB.Comparisons.Where(c => c.UserID == this.UserID).ToArray(); Here's the code in the View where I try to use An...

Razor View Engine and jQuery

Hi, does anybody know how to force Razor View engine to print exact line which is under foreach loop. Code follows : @section head{ <script type="text/javascript" src="@Url.Content("~/Content/Scripts/jquery-1.4.1.js")"></script> <script type="text/javascript" src="@Url.Content("~/Content/Scripts/jquery.progressbar.min.js")"></script> ...

How to specify default LayoutPage in Razor? [ASP.NET MVC 3]

Hi, I want to specify (in one place) a default layout page in Razor, so that I can delete this: @{ LayoutPage = "~/Views/Shared/_Layout.cshtml"; } from every .cshtml file I have. But I don't know how... Any ideas? I'm using Razor engine from ASP.NET MVC 3 Preview 1. ...

ASP MVC 2 + Razor - Child actions are not allowed to perform redirect actions.

Hello, In _Layout.cshtml file I have following entry: @Html.Action("LoadPagesStructure", "Page") Inside PageController class, LoadPagesStructure methos looks following: [ChildActionOnly] public ActionResult LoadPagesStructure() { ViewModel.Pages = new List<string>() {"page1", "page2", "page3"}; return View(); } Fi...

What will be the designer surface for the razor view engine?

Razor looks like a winner for developers...close to the metal, yet quick and efficient. As a developer who is not good with a designer's stylus pen, at some point I want to pass my ham-handed design to a professional designer. What will be the design surface that such a designer will use? Will Expression Web be enabled with a knowled...

ASP.NET MVC3 version release

Currently I am using ASP.NET MVC 3 version with Razor View Engine. Sometimes it is difficult to work with the ".cshtml" files without having intellisense. Do you have any information as to the release date of original version that supports intellisense? ...

'SampleApp.MvcApplication' is not allowed here because it does not extend class 'Microsoft.WebPages.WebPageHttpApplication'

I have created a sample project using ASP.NET MVC 3 Web Application (Razor) template. When I run my application I get this error 'SampleApp.MvcApplication' is not allowed here because it does not extend class 'Microsoft.WebPages.WebPageHttpApplication' Where should i look for the problem? ...

Escape @ character in razor view engine

A simple question though. I am creating a sample AP.NET MCV 3 site using Razor as view engine. The razor syntax starts with @ character e.g. @RenderBody(). If I write @test on my cshtml page it gives me parse error CS0103: The name 'test' does not exist in the current context. How do i escape '@' character? ...

Is it possible to use Razor View Engine outside asp.net

If I look at the Razor View Engine, then I see a very nice and concise syntax that is not particularly tied to generating html. So I wonder, how easy would it be to use the engine outside asp.net in a "normal" .net environment for example to generate text, code,... Any pointer, example, comment or explanation is welcome. ...

HttpHandler for Asp.NET MVC application

For general ASP.NET WebForms applications, the web page derives from Page class which implements IHttpHandler that servers actual web request. In ASP.NET MVC the webpage base class is System.Web.Mvc.ViewPage that also derives from Page class which in turn implements IHttpHandler. But in the ASP.NET MVC Razor, the "cshtml" file derives ...

Razor syntax PHP equivalent

Is there an equivalent to the new ASP.NET razor syntax in PHP? ...