ASP.NET控件呈现一个< D​​IV> [英] ASP.NET control to render a <div>

查看:149
本文介绍了ASP.NET控件呈现一个< D​​IV>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET Label控件似乎呈现<跨度> 标签,但有一个服务器控件中的&LT渲染HTML ; DIV>

The Label control in ASP.NET seems to render <span> tags, but is there a server control to render HTML within a <div>?

当然,我可以设置显示:块,它可能看起来是一样的,但我宁愿不div的嵌套里面跨越。此外,我倒是preFER不使用&LT;%= MyVariable的%&GT; ,因为这可能不是很好的回发的行为

Sure, I could set display: block and it might look the same, but I'd rather not be nesting divs inside spans. Also I'd prefer not to use <%= MyVariable %> because that might not behave nicely on postbacks.

任何建议,请?

推荐答案

我认为你需要<一个href="http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlgenericcontrol.aspx"><$c$c>HtmlGenericControl类。它有它接受一个字符串变量,它初始化的新实例构造的 HtmlGenericControl 类与指定的标记:

I think you need HtmlGenericControl class. It has a constructor which accepts a string variable which initializes a new instance of the HtmlGenericControl class with the specified tag:

var div = new HtmlGenericControl("div");

也有的innerHTML 的InnerText 属性(你在注释中的previous提到了这一点答案)。

It is also has InnerHtml and InnerText properties (you mentioned this in a comment to the previous answer).

这篇关于ASP.NET控件呈现一个&LT; D​​IV&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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