強く型付けされたモデルを操作する部分的なビューがあります。html ヘルパー メソッドでオンザフライでモデルを部分ビューにマップし、レンダリングされた html を返すことは可能ですか?
これが可能かどうか疑問に思っている疑似コードです。
public static MvcHtmlString ContentRating(this HtmlHelper html, ContentKey contentKey)
{
ContentRatingModel contentRatingModel = new ContentRatingHelper().GetContentRatingModel(contentKey);
// map my partial view which is named "ContentRating.cshtml" to contentRatingModel
return new MvcHtmlString(string.Format("the html output of mapping");
}
以下のように、ビューでこのヘルパー メソッドを使用します。
@Html.ContentRating(ContentKey.Test)