如何使用 C# 添加 html 样式容器?
我需要在特定页面的部分中添加 HTML 样式容器,如下所示:
<style>
#mycontrol
{
color:#ff0000;
}
</style>
虽然有很多方法可以做到这一点,但我正在考虑从 System.Web.UI.HtmlControls 命名空间实例化 HtmlControl 并简单地呈现它在页面上。但是,我只发现 HtmlGenericControl 是最接近的候选者 - 是否有更合适的控件可以使用,或者我是否必须使用其他方法?
I need to add a HTML style container in the section of a particular page, like so:
<style>
#mycontrol
{
color:#ff0000;
}
</style>
Although there are quite a few ways of doing this I was thinking about instantiating a HtmlControl from the System.Web.UI.HtmlControls namespace and simply render it on the page. However I only found the HtmlGenericControl to be the closest candidate - is there a more suitable control I can use or do I have to use another approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试类似
HTH
Ivo Stoykov 的东西
Try something like
HTH
Ivo Stoykov
你可以试试这个:
you can try this:
您可以使用 HtmlGenericControl - 或者如果您愿意,也可以使用 Literal。
更好的方法可能是使用
You can use an HtmlGenericControl - or you can use a Literal if you want to.
A better way might be to insert this into your HTML Header using something like this code from http://msdn.microsoft.com/en-us/library/system.web.ui.page.header.aspx