Usercontrols Not Showing

Posted on 2006-05-02
Last Modified: 2008-03-03
Under ASP.NET v1.1 we've created a web application which contains a single user control (main.ascx).  The usercontrol is composed of a single ASP:placeholder.  This control executes code to dynamically load other user controls (via LoadControl) and makes use of reflection to obtain the parameters of their respective class.  Once the dynamicly loaded user control is read in, it is added to the ASP:placeholder to be shown on screen.  

The problem we're facing is on Postback the dynamically loaded controls aren't be reshown on screen.  The same code is executing (similar to the first time through) but this time the web page is blank.  Steping thru the code after postback I can see the ASP:placeholder contains the dynamically loaded user control.

Also, each dynamically loaded user control contains event handlers for button clicks on buttons contained within the user control page.  These events are never called on clicking the buttons -- there is a post back, which calls the original default.aspx page and the main.ascx control.

Am i working with placeholders, controls, and postbacks incorrectly?
Question by:barkin
    1 Comment
    LVL 6

    Accepted Solution

    Every dynamic loaded objects you must load on every postback (Page_init, Page_load event handlers), not only on first load of Page.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now