在剃刀网络辅助使用HTML助手 [英] Using html helpers in Razor web helper
本文介绍了在剃刀网络辅助使用HTML助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个网页剃刀助手是这样的:
I am trying to create a Razor web helper something like this :
@helper DisplayForm() {
@Html.EditorForModel();
}
但是,这给出了错误CS0103:'HTML'这个名字并不在目前的情况下存在。
有没有什么办法对Web助手中引用HTML佣工?
Is there any way to reference html helpers within web helpers?
推荐答案
您可以从上下文投静态页面属性为正确的类型:
You can cast the static Page property from the context to the correct type:
@helper MyHelper() {
var Html = ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Html;
Html.RenderPartial("WhatEver");
@Html.EditorForModel();
}
这篇关于在剃刀网络辅助使用HTML助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文