3

UPDATE

  protected override void CreateChildControls()
        {
            if (!this._error)
            {
                try
                {
                    base.CreateChildControls();

                    UpdatePanel updatePanel1 = new UpdatePanel();
                    updatePanel1.ID = "udpItemListingWebPart";
                    updatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional;

                    ContentService_VWPUserControl control = Page.LoadControl(_ascxPath) as MyUserControl_VWPUserControl; 

                    if (control != null)
                        control.WebPart = this;
                    //Controls.Add(control);
                    updatePanel1.ContentTemplateContainer.Controls.Add(control);
                }
                catch (Exception ex)
                {
                    this.HandleException(ex);
                }
            }
        }

END UPDATE

the below code is suppose to work but somehow if i have UpdatePanel then it does not render... no error nothing just dont render the web site in my case (http://www.cnn.com) any help?

protected override void OnPreRender(EventArgs e)
{

 base.OnPreRender(e);

UpdatePanel updatePanel1 = new UpdatePanel();
updatePanel1.ID = "udpItemListingWebPart";
updatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional; 
PageViewerWebPart oWebPart = new PageViewerWebPart();
oWebPart.ContentLink = "http://www.cnn.com"; 
updatePanel1.ContentTemplateContainer.Controls.Add(oWebPart);

}
2

finally i figured out and below is the updated code: hope this will help others..

protected override void CreateChildControls()
        {
            if (!this._error)
            {
                try
                {
                    base.CreateChildControls();

                    UpdatePanel updatePanel1 = new UpdatePanel();
                    updatePanel1.ID = "udpItemListingWebPart";
                    updatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional;

                    ContentService_VWPUserControl control = Page.LoadControl(_ascxPath) as MyUserControl_VWPUserControl; 

                    if (control != null)
                        control.WebPart = this;
                    //Controls.Add(control);
                    updatePanel1.ContentTemplateContainer.Controls.Add(control);
                    this.Controls.Add(updatePanel1);
                }
                catch (Exception ex)
                {
                    this.HandleException(ex);
                }
            }
        }
1

You need to create the updatepanel in CreateChildControls instead of prerender and add it to the controls collection for it to work correctly.

  • i changed it to CreateChildControls still the same, I have updated my question – Nick Kahn Sep 8 '11 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.