在控制器使用的HtmlHelper [英] Using HtmlHelper in a Controller

查看:64
本文介绍了在控制器使用的HtmlHelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在一个控制器来使用的HtmlHelper,换例如得到文本框(...)方法?不是说我不会写它自己生成的HTML,但我只是想了解如何工作的,所以我可以创造最佳的解决方案。

Is it possible to use HtmlHelper in a controller, for-example to get the TextBox(...) method? not that I can't write the html that it generates myself, but I just want to understand how this works so I can create the best solution.

在此先感谢!

推荐答案

下面是改编自的

var h = new HtmlHelper(new ViewContext(ControllerContext, new WebFormView("omg"), new ViewDataDictionary(), new TempDataDictionary()), new ViewPage());
h.TextBox("myname");

请注意,这是一个黑客,是可以做到的,但我不认为有任何充分的理由这样做...

Note that this is a hack, it can be done but I don't think there's any good reason to do this...

这篇关于在控制器使用的HtmlHelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆