Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

ASP.NET : inserting HTML into response output

I want to write some HTML into my current ASPX page, runtime. For e.g. I want to add a html map attribute to the page - if I try itusing Response.Write - it writes it to the top of the output, even before the HTML tags are formed. How do I write it so that the final output HTML actually has my insert "within it", preferably in the end of file before the html tags end.

ASP.NET loser
Wednesday, May 04, 2005

One approach is to add a label or panel to the .aspx page and your html to that.

Charles Reich
Wednesday, May 04, 2005

This is what the PlaceHolder control is for.

Jeff Mastry
Thursday, May 05, 2005

> This is what the PlaceHolder control is for.

Not really.  The PlaceHolder is a container for dynamically-generated server controls: if you just want to insert some literal HTML, the Literal control is the best bet:

The Label and Panel controls suggested by Charles Reich render as SPAN and DIV respectively, so aren't appropriate if all you want to render is some literal HTML.

Joe
Thursday, May 05, 2005

I figured the literal control was the best way to do it - so I used that. Placeholders have a different "place", usually for loading user controls into a specific place. That wasn't what I was looking for.

Nevertheless, thanks everyone!

ASP.NET loser
Thursday, May 05, 2005

Yep - I stand humbly corrected. :)

Jeff Mastry
Friday, May 06, 2005

I find an easy way to accomplish this is to add an id and and runat="server" to the HTML tag that I want contain dynamic content. This way I know what the markup around it is going to be and as a result it seems easier to style it using CSS.

Wade
Friday, May 06, 2005

*  Recent Topics

*  Fog Creek Home