Solved

Mixing static & dynamic content on the same page

Posted on 2004-08-19
1
193 Views
Last Modified: 2011-09-20
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" >
<HTML>
...

so obviously this messes up my whole layout ...

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

Thanks
Peter
0
Comment
Question by:Pete2003
1 Comment
 
LVL 2

Accepted Solution

by:
vijay_a73 earned 500 total points
ID: 11841685
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" %>
<html>
<head>
   <script runat="server">
      void Page_Load(Object sender, EventArgs e)
      {
         HtmlButton myButton = new HtmlButton();

         myButton.InnerText = "Button 1";
         PlaceHolder1.Controls.Add(myButton);

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

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

         myButton = new HtmlButton();
         myButton.InnerText = "Button 4";
         PlaceHolder1.Controls.Add(myButton);
      }
   </script>
</head>
<body>
   <form runat="server">
      <h3>PlaceHolder Example</h3>
      <asp:PlaceHolder id="PlaceHolder1"
           runat="server"/>
   </form>
</body>
</html>


0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now