开发者

printing html in asp.net

What's the best way for print html?

I开发者_如何学编程 can do this:

container.InnerHtml = "<input type=\"text\" ...runat=..>"; 

where container is an ref to an <div> HTML

but I have impression that this it's not the correct mode. can someone point me for right direction?

Thanks in advance.


As Paolo has mentioned, using the <asp:PlaceHolder> is a good way to inject HTML at runtime. Not only does it allow for you to output plain html <div><p>Hello World!</p></div> but it also allows you to dynamically add other asp.net controls.

For your example above you could do

.aspx

<asp:PlaceHolder id="PlaceHolder1" runat="server" />

c#

TextBox textBox1 = new TextBox();
textBox1.Id = "textBox1";
textBox1.TextMode = TextBoxMode.SingleLine;

PlaceHolder1.Controls.Add(textBox1);

This then allows you to access the value which you enter into textBox1 dynamically.


if by "printing HTML" you mean injecting it at runtime in a ASP.NET webform, you may try using a PlaceHolder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜