Mixing static & dynamic content on the same page

Hi All,

I have a static ASPX page with some ASP edit boxes, labels, etc .. I now want to put some dynamicly generated data inbetween the components.

I have tried the follwing:

Create ASCX component which generates the dynamic data on it's Page_Load()
It uses the Response.Write() to generate the dynamic content. I do not use Response.End() here so that the whole page can complete

I then put the component onto my ASPX page between the components I want it to display ...

This does not work .. .

What id does is it generates the dynamic content on top of the page and then the rest of the page... eg:

<table> ... </table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

so obviously this messes up my whole layout ...

How can I specify the exact position of my dynamic code ...

Who is Participating?
vijay_a73Connect With a Mentor Commented:
You can use PlaceHolder Control.  Keep the place holder where ever you want in the aspx. Then add your controls dynamically in the code behind.

Sample Code (from MSDN):
<%@ Page Language="C#" AutoEventWireup="True" %>
   <script runat="server">
      void Page_Load(Object sender, EventArgs e)
         HtmlButton myButton = new HtmlButton();

         myButton.InnerText = "Button 1";

         myButton = new HtmlButton();
         myButton.InnerText = "Button 2";

         myButton = new HtmlButton();
         myButton.InnerText = "Button 3";

         myButton = new HtmlButton();
         myButton.InnerText = "Button 4";
   <form runat="server">
      <h3>PlaceHolder Example</h3>
      <asp:PlaceHolder id="PlaceHolder1"

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.