Hello all,
I have a webpart in a control that I am using on a webpage. The webpage uses a master page and there is a content holder in the MP that can hold controls for alignment/design issues. Everything works well with this but the webpart control. When i put the webpart in the container i lose the ability to move the webparts around but as soon as i move it out of the container it works fine.
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);
}
}
displaymode.ascx
MyWebPartManager webPartManager;
public void Page_Init(object sender, EventArgs e)
{
Page.InitComplete += new EventHandler(InitComplete);
}
public void InitComplete(object sender, System.EventArgs e)
{
webPartManager = (MyWebPartManager)WebPartManager.GetCurrentWebPartManager(Page);
String browseModeName = WebPartManager.BrowseDisplayMode.Name;
foreach (WebPartDisplayMode mode in
webPartManager.SupportedDisplayModes)
{
String modeName = mode.Name;
if (mode.IsEnabled(webPartManager))
{
ListItem listItem = new ListItem(modeName, modeName);
ddlDisplayMode.Items.Add(listItem);
}
}
}
public void ddlDisplayMode_SelectedIndexChanged(object sender, EventArgs e)
{
String selectedMode = ddlDisplayMode.SelectedValue;
WebPartDisplayMode mode = webPartManager.SupportedDisplayModes[selectedMode];
if (mode != null)
{
webPartManager.DisplayMode = mode;
}
}
public void Page_PreRender(object sender, EventArgs e)
{
ListItemCollection items = ddlDisplayMode.Items;
int selectedIndex = items.IndexOf(items.FindByText(webPartManager.DisplayMode.Name));
ddlDisplayMode.SelectedIndex = selectedIndex;
}