How to create HTML controls a runtime

J

Jaime Stuardo

Hi all..

I have an ASPX page that has a form. It has a button that when it is
pressed, the submit is sent to the same page. The form is placed inside a DIV
control.

After the form is posted and the same page is reloaded, I need to place an
IFRAME below the form because I have to load a whole page (dynamically
determined) into the frame (that page may has PDF content type, that's why I
need to use other frame).

If I use Response.Write("<IFRAME....">, the frame is placed above all HTML
tags, and obviously, it didn't work.

I have read something about HTMTextWriter, but after a lot of tries (and
without finding a good example), I still cannot render HTML tags dinamically
placed where I want.

I don't want to use FRAMESET, so any hint you can give me to achieve this
will be very helpful.

I'm using ASP.NET 2.0

Thanks
Jaime
 
B

Brock Allen

Create a HtmlGenericControl and then add it into the server side control
hierarchy. This means you'll have to find some other control on the form
to add it under, like the Form itself:

HtmlGenericControl iframe = new HtmlGenericControl("IFRAME");
iframe.Attributes.Add(..., ...);
Page.form1.Controls.Add(iframe);

Or better yet, create the IFRAME as a server side control that's initially
hidden, then make it visible as you need it. That might be an easier approach
for you.
 
J

Jaime Stuardo

Thanks brock for answering..

I have tested it. IFRAME is shown in the page but not where I want.

I have this HTML structure:

<FORM>
<DIV>
<TABLE>

</TABLE>
</DIV>
</FORM>

When I add the IFRAME it always starts from the top of the page, staying on
the back of the form. If I could place it before the </DIV> element, it would
be shown after the table.

It seems that the DIV element isn't accesible by the server in order to add
controls dynamically. I have tried a panel control and a placeholder control
but without success.

Finally, I tried to get the height of the form so that I could force he top
position of the IFRAME, but without success either.

How can I do it?

According to your second suggestion. How can I create a server side IFRAME?
I have just added an IFRAME tag using HTML view, but that way I cannot
refresh the page that is intended to be shown in the frame. That's why I'm
trying to create it dynamically in Page_Load event.

thanks
Jaime
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top