Dynamic HTML

wtbonnell

Freshman
Joined
Oct 6, 2003
Messages
32
I am using Asp.Net (w/ C#) and I am dynamically generating a stringbuilder to create html code. My question is, how do you control where the code goes on the .aspx page when using Response.Write(htmlStringContent).
Currently the info just appears at the top of the page and I want it to appear within a column (<td></td>) that I already have established as a holder.

Thanks
 
Rather than using the response object you will probably be better of placing a literal control where you require the HTML to be and then assign the result of the string builder to that.
Out of curiosity what does this html string contain as there may be built in controls that require less effort than building your own html.
 
The html string will have just a table with one row and two columns. In each column will have <a href> tags

<table>
<tr>
<td>
<a href='someDynamicData'>moreDynamicData</a>
<\td>
<\tr>
</table>

By the way, do you have an example of using literal controls? I am relatively new to .net?

Thanks
 
the html would look like
Code:
<table>
    <tr>
        <td>
	    <asp:Literal id="Literal1" runat="server"></asp:Literal>
	</td>
    </tr>
</table>
and the code behind would be
Visual Basic:
Literal1.Text = " <a href='someDynamicData'>moreDynamicData</a>"

However if you just want a simple link you may be better of with a HyperLink control
Code:
<table>
	<tr>
		<td>
			<asp:HyperLink id="HyperLink1" runat="server">HyperLink</asp:HyperLink>
		</td>
	</tr>
</table>
with a code behind like
Visual Basic:
HyperLink1.Text = "moreDynamicData"
HyperLink1.NavigateUrl = "http://www.b3ta.com"  'or wherever
 
Back
Top