I have created a custom list in a SharePoint site and generated a Visual Studio 2008 project using SharePoint Solution Generator. I can package this as a feature and install it. It runs fine on my server.
After testing this out, I've been able to add a custom masterpage to the feature which is deployed to the _catalogs/masterpage folder. Here it is:
<Elements Id="2196306F-3F37-40b5-99CF-42E89B93888A" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DefaultMasterPage" Url="_catalogs/masterpage" RootWebOnly="FALSE">
<File Url="gcbranding.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
</Module>
</Elements>
Now that I have a custom masterpage in my site, I would like to have this used for the creation of new items. But I don't want to have to set the master from SharePoint Designer.
Going back to the generated solution, it has NewForm.aspx etc. with the list schema. How do I...
- Customize the form that is displayed for new items, and have it redirect to a thankyou.aspx page rather than showing all the list items?
- Set the url to the master page correctly?
I'm lost on point number 1. Do I need to create a custom webpart and embed that in NewForm.aspx?
On point 2 I have made some headway but have run into an issue. If I set the master like this in my NewForm.aspx...
MasterPageFile="~/masterurl/gcmaster.master"
It will install OK, but when I hit the site I get an error because ~ is not allowed in the URL. If I use _catalogs/masterpage in the directive, it will not find the master because the URL is relative. Only this code seems to work:
MasterPageFile="../../_catalogs/masterpage/gcmaster.master"
What's the best practice way of setting the master page file in SharePoint, when deploying a custom feature/solution?