Solved

Mixing static & dynamic content on the same page

Posted on 2004-08-19
1
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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