简体   繁体   English

MVC3 HTML Helper方法访问父容器?

[英]MVC3 Html Helper Method To Access Parent Container?

How would I access a Parent Container to change its css in an Html Helper Method? 如何在HTML帮助器方法中访问父容器以更改其CSS?

I know how to return Html but I don't know if its possible to access the Parent Container when Html Helpers are in fact supposed to render Html, not change existing markup. 我知道如何返回HTML,但我不知道当HTML Helper实际上应该呈现HTML而不更改现有标记时是否有可能访问父容器。

If not how could I add HtmlStrings together like: 如果没有,我怎么能像这样将HtmlStrings加在一起:

var htmlstring = htmlHelper.ActionLink(linkText, actionName, controllerName);
return new HtmlString("<li>") + htmlstring + new HtmlString("</li>");

Any suggestions? 有什么建议么? Thanks. 谢谢。

To add Html Strings together or rather the ActionLink and text use this: 要一起添加HTML字符串,或者将ActionLink和文本添加在一起,请使用以下命令:

new HtmlString("<li>" + 
               htmlHelper.ActionLink(linkText, actionName, controllerName)
               + "</li>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM