HtmlGenericControl没有标签 [英] HtmlGenericControl Without Tag

查看:195
本文介绍了HtmlGenericControl没有标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.NET C#。

Asp.NET C#.

这是可能没有标签来创建HtmlGenericControl?如果我写:

It is possible to create HtmlGenericControl without tag ? If i write :

HtmlGenericControl o_My_Control = New HtmlGenericControl();

它会自动返回一个span元素。我需要一个用户控件,因为我必须添加这个控件到另一个用户控件Control.Add(o_My_Control),我需要直接追加HTML。我用o_My_Control.innerHTML。

It automatically returns a span element. I need an UserControl because i must add this control into an another usercontrol Control.Add(o_My_Control) and i need to directly append html. I use o_My_Control.innerHTML.

你能帮我找到解决办法?

Can you help me to find solution ?

推荐答案

一个HtmlGenericControl是用来重新present一个HTML元素的控制,因此它必须有一个名称。你可以提供一个或如果你不这样做,它使用间距。

A HtmlGenericControl is a control used to represent an HTML element and thus it has to have a name. You can either provide one or if you don't it uses the default value of "span".

如果你要放到网页一些文字直接那么你可能想看看literalControl(<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.literalcontrol.aspx\">http://msdn.microsoft.com/en-us/library/system.web.ui.literalcontrol.aspx )。这个控制的目的是用于HTML元素,文本和在ASP.NET页面中的任何其他字符串不需要在服务器上处理。

If you have some text you want to put into the page directly then you might want to look at the literalControl ( http://msdn.microsoft.com/en-us/library/system.web.ui.literalcontrol.aspx ). This control is designed to be used for "HTML elements, text, and any other strings in an ASP.NET page that do not require processing on the server".

所以,你可以只是做

myUserControl.Controls.Add(new LiteralControl(myHTMLstring));

和避免需要在所有使用的innerHTML。

And avoid needing to use the innerHTML at all.

这篇关于HtmlGenericControl没有标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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