R100
R100

Reputation: 481

Add Custom Webparts to Custom ASPX Page in SharePoint 2010

I am creating a custom aspx page to deploy to my SharePoint 2010 site.

Is it possible to have regions in my custom aspx page to allocate webparts to?

I am planning on creating some custom webparts and being able to move them around the page if needed would be a benefit for my aspx page.

Thanks.

Upvotes: 0

Views: 5215

Answers (1)

djeeg
djeeg

Reputation: 6765

Yes, use the standard WebPartZones with the sharepoint master pages (so you can add/configure the webparts)

    <%@ Page language="C#" MasterPageFile="~masterurl/default.master"    Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"  %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Import Namespace="Microsoft.SharePoint" %> 
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
        <WebPartPages:WebPartZone runat="server" FrameType="None" ID="Main" Title="loc:Main"></WebPartPages:WebPartZone>
    </asp:Content>

If you dont have the sharepoint master page, or any master page, you could still have the zones, but it is going to be hard work setting up the webpart editing tools.

Upvotes: 3

Related Questions