To deploy an ASPX page using Module in Visual Studio project. The web part should be deployed with a PageLayout applied to it. Else a page is going to be created without a page layout attached. The name of the page is "Sample.aspx" and PageLayout is "DefaultPageLayout.aspx". "GSM" is the name of our module.
- Open Visual Studio 2010.
- File > New > Sharepoint > Empty Sharepoint Project > Name it "Sample"
- Right click project > Add a Module > Name "Something".
- Remove Sample.txt. Add a file(Sample.aspx) to the module.
- Make the below given changes to the "Element.xml".
- Right click project and deploy.
- Visit your website.
- Site Actions > Edit Site
- Click "Add a Web Part". On the top ribbon.
You should now be able to see the page with page layout applied to it.
Change in Element.xml
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="GSM" Url="Pages"> <File Path="GSM\Sample.aspx" Url="Sample.aspx" Type="GhostableInLibrary"> <Property Name="Title" Value="Sample Title"/> <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/DefaultPageLayout.aspx, Default Page Layout"/> </File> </Module> </Elements>
Hope this is helpfull for you!