title: SharePoint - How can I customize NewForm.aspx in custom feature?
body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>&lt;Elements Id="2196306F-3F37-40b5-99CF-42E89B93888A" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
      &lt;Module Name="DefaultMasterPage" Url="_catalogs/masterpage" RootWebOnly="FALSE"&gt;
        &lt;File Url="gcbranding.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" /&gt;
      &lt;/Module&gt;
  &lt;/Elements&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>Going back to the generated solution, it has NewForm.aspx etc. with the list schema. How do I...</p>
  
  <ol>
  <li>Customize the form that is displayed for new items, <em>and have it redirect to a thankyou.aspx page</em> rather than showing all the list items? </li>
  <li>Set the url to the master page correctly?</li>
  </ol>
  
  <p>I'm lost on point number 1. Do I need to create a custom webpart and embed that in NewForm.aspx?</p>
  
  <p>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...</p>
  
  <pre><code> MasterPageFile="~/masterurl/gcmaster.master"
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>MasterPageFile="../../_catalogs/masterpage/gcmaster.master"
  </code></pre>
  
  <p>What's the best practice way of setting the master page file in SharePoint, when deploying a custom feature/solution?</p>