I am deploying a list using Visual Studio 2010 that is based on a content type I created. The list also uses custom new/edit/display forms whcih I created using SharePoint Designer. I achieve this all as follows:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x0100730B35B9AD3755498EF8D60B1E3E0AFE01"
Name="Custom Content Type"
Group="Custom"
Description=""
Inherits="TRUE"
ReadOnly="TRUE"
Version="0">
<FieldRefs>
// Code omitted for readability
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<FormUrls xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url">
<Display>Lists/ListName/CustomDispForm.aspx</Display>
<Edit>Lists/ListName/CustomEditForm.aspx</Edit>
<New>Lists/ListName/CustomNewForm.aspx</New>
</FormUrls>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
Note the FormUrls section -- this instructs SharePoint to always load the specified form for this content type (as appposed to the default OOTB list forms). See MSDN.
To create my custom forms, I simply created a copy of the OOTB "NewForm.aspx" file and tweaked the layout a little. Nothing drastic.
So far this all works great.
My only problem is that "NewForm.aspx" contains some hardcoded list ID and URL references which I need to replace (with a token?). An example is in the SPDataSource control:
<DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" SelectCommand="..." UseInternalName="True" UseServerDataFormat="True">
<SelectParameters>
<WebPartPages:DataFormParameter ParameterKey="ListItemId" PropertyName="ParameterValues" DefaultValue="0" Name="ListItemId"></WebPartPages:DataFormParameter>
<WebPartPages:DataFormParameter ParameterKey="weburl" PropertyName="ParameterValues" DefaultValue="http://devsite" Name="weburl"></WebPartPages:DataFormParameter>
<WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{40047E88-C8E1-4E9B-88E6-2FD75A9D8533}" Name="ListID"></WebPartPages:DataFormParameter>
</SelectParameters>
What can I replace the hardcoded URL and ListID paramter values with so that my custom form will work with any list that is based on this content type in the future?