How to insert HTML strings in ASP.net

G

Guest

Hi, friends,

In ASP, we use
obj = CreateObject("com.dll")
obj.GetHTMLText(inVal, outHTMLTxt1, outHTMLTxt2)
to get different HTML strings based on input values.

Then, we insert them into proper location of HTML something like the
following:
<table>
<% = outHTMLTxt1 %>
</table>

In ASP.net, how do we do this? I looked into Page_Load() event, and I could
get different HTML strings, but I did not know how to insert them into proper
location of HTML.

Any sample source code or reference papers? Help please.

Thanks a lot
 
G

Guest

you can either use a control, which is what I recommend, or you can still do
inline coding with asp.net.. the <% %> is still usable.
 
G

Guest

But, I do not have object, such as com.dll, any more. I created different
HTML strings in Page_load(). How can I instert it in HTML? Any sample code?
 
G

Guest

For exmple, in Page_Load()

newHTMLStr = "<tr><td>....";

If I use Reponse.Write(newHTMLStr), all those <tr><td> element will be on
the top of web page. But, I want to inert those <tr><td> elements into
<table></table>. This <table></table> element was already created when I
designed the web page by draging and droping it in a web form.

My question is: How to insert this new created newHTMLStr into pre-existing
<table></table> element so that we have cells in the previouly empty
<table></table> element.
 
J

Jeremy S.

Check out the Literal control

Basically you would declare a Literal control in your HTML table - where you
want the inserted HTML to go. Then, in your code behind, you'd set the .Text
property of the Literal control to your HTML string. It's that simple.

If you want your HTML to be styled, then you'd have to use inline CSS or set
the css class property directly in the HTML string you are inserting.

http://www.w3schools.com/aspnet/control_literal.asp

http://msdn.microsoft.com/library/d...rfsystemwebuiwebcontrolsliteralclasstopic.asp


-HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top