【发布时间】:2011-06-14 14:26:44
【问题描述】:
我在 ASP.NET MVC 3 中有一个完美运行的 ascx 编辑器模板,并尝试将其转换为 razor:
Ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Inventory.Models.ProductCategory>" %>
<%= Html.Telerik().DropDownList()
.Name("ProductCategory")
.BindTo(new SelectList((IEnumerable)ViewData["ProductCategories"], "Id", "Name"))
%>
剃须刀:
@inherits System.Web.Mvc.ViewUserControl<Inventory.Models.ProductCategory>
@(Html.Telerik().DropDownList()
.Name("ProductCategory")
.BindTo(new SelectList((IEnumerable)ViewData["ProductCategories"], "Id", "Name"))
)
我重命名了 ascx,这样当 ASP.NET 选择编辑器模板时它不会发生冲突,我保存了带有 cshtml 扩展名的 razor 文件,等等。但是在运行时,我得到了这个错误:
CS0115: 'ASP._Page_Views_Shared_EditorTemplates_ProductCategory_cshtml.Execute()': no suitable method found to override
Line 44: }
Line 45:
Line 46: public override void Execute() {
Line 47:
Line 48: WriteLiteral("\r\n");
我做错了什么? ASP.NET MVC 不识别 Razor EditorTemplates 吗?
【问题讨论】:
标签: asp.net-mvc telerik asp.net-mvc-3 razor editortemplates