Asp.net 母版页中的Web部件控件

Asp.net 母版页中的Web部件控件,asp.net,user-controls,master-pages,web-parts,Asp.net,User Controls,Master Pages,Web Parts,我在网页上使用的控件中有一个Web部件。该网页使用母版页,MP中有一个内容持有者,可以控制对齐/设计问题。除了webpart控件之外,其他一切都可以很好地使用它。当我将Web部件放入容器中时,我失去了移动Web部件的能力,但一旦我将其移出容器,它就可以正常工作 default.aspx /// <summary> /// Set the selected item equal to the current display mode. /// </

我在网页上使用的控件中有一个Web部件。该网页使用母版页,MP中有一个内容持有者,可以控制对齐/设计问题。除了webpart控件之外,其他一切都可以很好地使用它。当我将Web部件放入容器中时,我失去了移动Web部件的能力,但一旦我将其移出容器,它就可以正常工作

default.aspx

/// <summary>
        /// Set the selected item equal to the current display mode.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Page_PreRender(object sender, EventArgs e)
        {
            MyWebPartManager wpm = (MyWebPartManager)WebPartManager.GetCurrentWebPartManager(Page);


            Control control = (Control)Master.FindControl("divReturnBack");
            if (control != null)
            {
                control.Visible = true;
                control.Controls.Add(DisplayModeMenul1);
            }
        }

我把这段代码移到了回发部分之外,现在可以正常工作了

// move to container in masterpage
            Control control = (Control)Master.FindControl("divReturnBack");
            if (control != null)
            {
                control.Visible = true;
                control.Controls.Add(DisplayModeMenul1);
            }
// move to container in masterpage
            Control control = (Control)Master.FindControl("divReturnBack");
            if (control != null)
            {
                control.Visible = true;
                control.Controls.Add(DisplayModeMenul1);
            }