Solved

Mixing static & dynamic content on the same page

Posted on 2004-08-19
1
194 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Data Saving 5 56
COnsume rest client 6 36
Definitions and default visual studio colors 5 58
Error in JQuery 5 39
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

16 Experts available now in Live!

Get 1:1 Help Now