ASP.NET MVC 3 で完全に機能する ascx エディター テンプレートがあり、それをかみそりに変換しようとしました。
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 拡張子で保存しました。しかし、実行時に次のエラーが発生します。
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");
私は何を間違っていますか?Razor EditorTemplates は ASP.NET MVC によって認識されませんか?