?
Solved

Mixing static & dynamic content on the same page

Posted on 2004-08-19
1
Medium Priority
?
205 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

862 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