Groups | Blog | Home
all groups > asp.net > july 2003 >

asp.net : How to insert dynamically generated HTML into the <body> of an ASP.NET page?


bruce barker
7/24/2003 5:36:22 PM
a literal control won't work because you cannot nest forms in html. the
easisest way is to write a function that renders the html and call from the
page:

<body>
<% RenderBuyForm(); %>
<form runat=server id=myform>
......
</form>
</body>




[quoted text, click to view]

Rick Spiewak
7/24/2003 5:57:46 PM

Thanks for your suggestion. But, anything which creates another <form>
tag at design time causes errors. I'm looking for an event (for example)
to tie into which lets me emit HTML inside of the <body> tag. Or, even
inside the <html> tags, since more than one <body> is (still?)
technically OK.


*** Sent via Developersdex http://www.developersdex.com ***
Rick Spiewak
7/24/2003 6:22:40 PM
I need to generate a "buy" button as part of an ASP.NET page - this consists
of a small HTML form with hidden fields, conforming to the requirements of a
merchant credit card processor. PayPal is similar.

I'm succeeding in doing this by using Writer.Write to emit my HTML, at least
as far as getting it to work.

However, depending on where I put MyBase.Render(Writer), I get my HTML
either before the header or after the end of the body of the HTML generated
by ASP.NET. Oddly enough, both Netscape and IE seem to be happy to handle
this. But, it looks ugly and is probably non-compliant.

Anyone have any ideas as to how to split the difference and get my added
HTML form into the <body>?

TIA

Rick Spiewak

Ken Cox [Microsoft MVP]
7/24/2003 6:29:59 PM
Off the top of my head, I wonder if adding a Literal server control to hold the
content would serve your purpose? It is made to sit inside the existing
server-side <form>. Maybe I've missed something?

Ken

[quoted text, click to view]
I need to generate a "buy" button as part of an ASP.NET page - this consists
of a small HTML form with hidden fields, conforming to the requirements of a
merchant credit card processor. PayPal is similar.

I'm succeeding in doing this by using Writer.Write to emit my HTML, at least
as far as getting it to work.

However, depending on where I put MyBase.Render(Writer), I get my HTML
either before the header or after the end of the body of the HTML generated
by ASP.NET. Oddly enough, both Netscape and IE seem to be happy to handle
this. But, it looks ugly and is probably non-compliant.

Anyone have any ideas as to how to split the difference and get my added
HTML form into the <body>?

TIA

Rick Spiewak


AddThis Social Bookmark Button