English 中文(简体)
Html GenericControl 无
原标题:HtmlGenericControl Without Tag

Asp.NET C#。

可以在没有标签的情况下建立HtmlGenericControl? 如果是:

HtmlGenericControl o_My_Control = New HtmlGenericControl();

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.

你们能否帮助我找到解决办法?

最佳回答

HtmlGenericControl是一种用来代表超文本元素的控制权,因此它必须有一个名字。 如果你不使用“全程”的缺省值,你可以提供一种或一种。

如果你有某些案文,你希望直接上页,那么你不妨看一下字面的Control(http://msdn.microsoft.com/en-us/library/system.web.ui.literal Control.aspx )。 这种控制旨在用于“超文本元素、文字和任何其它插图”。 不需要在服务器上处理联网网页”。

因此,你可以这样做。

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

And avoid needing to use the innerHTML at all.

问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签