Error while generating DateTime EditorTemplate

Dec 18, 2012 at 3:14 AM


GeneratedCodeAttribute("RazorGenerator", "" )] [System.Web.WebPages.PageVirtualPathAttribute("~/Views/Shared/EditorTemplates/DateTime.cshtml")]
public class DateTime : System.Web.Mvc.WebViewPage<DateTime?>

The code generated for the DateTime template will not compile.

 The reason is that the newly defined DateTime class takes precedence over the System.DateTime.

The class that is inherited should be:

System.Web.Mvc.WebViewPage <System.DateTime>



Hope you will look into this.

Dec 18, 2012 at 11:17 PM

What's the repro scenario?

Dec 19, 2012 at 7:09 PM
davidebbo wrote:

What's the repro scenario?

To reproduce, add the a DateTime View:


The scenario is that one is overriding the default DateTime template; pretty common


Dec 19, 2012 at 7:16 PM

But what is the content of this template? Or are you saying that you get this error even if your DateTime.cshtml is an empty file?

Dec 19, 2012 at 7:28 PM

My guess is that the problem is in your template itself. e.g. you might have something like '@model DateTime?' that needs to be '@model System.DateTime?' instead.

Dec 19, 2012 at 7:40 PM


I will try using the full type name, thanks