Error while generating DateTime EditorTemplate

Dec 18, 2012 at 3:14 AM

[System.CodeDom.Compiler.

GeneratedCodeAttribute("RazorGenerator", "1.5.0.0" )] [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.

Solution: 
The class that is inherited should be:

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


NOT

System.Web.Mvc.WebViewPage<DateTime>

Hope you will look into this.

Coordinator
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:

Views/Shared/EditorTemplates/DateTime.cshtml

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

 

Coordinator
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?

Coordinator
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

Awesome!

I will try using the full type name, thanks