Skip to content

Instantly share code, notes, and snippets.

@mattkruskamp
Created August 24, 2015 21:39
Show Gist options
  • Save mattkruskamp/cc697cf3461e4422c437 to your computer and use it in GitHub Desktop.
Save mattkruskamp/cc697cf3461e4422c437 to your computer and use it in GitHub Desktop.
Creating Webparts
<div>
<asp:WebPartManager ID=“WebPartManager1” runat=“server”>
</asp:WebPartManager>
<asp:DropDownList ID=“DropDownList1” runat=“server”>
</asp:DropDownList>
</div>
<div>
<asp:WebPartZone ID=“WebPartZone1” runat=“server”>
</asp:WebPartZone>
</div>
<div>
<asp:WebPartZone ID=“WebPartZone2” runat=“server”>
</asp:WebPartZone>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Set up the list of options
foreach (WebPartDisplayMode mode in this.WebPartManager1.SupportedDisplayModes)
// Add an item for each mode
this.DropDownList1.Items.Add(
new ListItem(mode.Name, mode.Name));
}
this.WebPartManager1.DisplayMode =
this.WebPartManager1.SupportedDisplayModes[
this.DropDownList1.SelectedValue];
}
protected void DropDownList1_SelectedIndexChanged1(
object sender, EventArgs e)
{
this.WebPartManager1.DisplayMode =
this.WebPartManager1.SupportedDisplayModes[
this.DropDownList1.SelectedValue];
}
<div>
<asp:WebPartZone ID=“WebPartZone1” runat=“server”>
<ZoneTemplate>
<asp:Calendar ID=“Calendar1” runat=“server” />
</ZoneTemplate>
</asp:WebPartZone>
</div>
<div>
<asp:WebPartZone ID=“WebPartZone2” runat=“server”>
<ZoneTemplate>
<asp:Button ID=“Button1” runat=“server” Text=“Button” />
</ZoneTemplate>
</asp:WebPartZone>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment