Project Description
Two example of ASP.NET forms for SharePoint content types.
First shows New item form with default values set from code behind.
Second shows a form with master-detail relationship between two fields of a content type.

Two small examples on how to use controls in custom forms for content types.

1. Custom form for SharePoint content type

To test it, deploy the solution, create a list, enable content types on the list and add the "ContentTypeCustomForms - MyContentType". Go to the Items tab and from the "New Item" menu, select "ContentTypeCustomForms - MyContentType". The new form should look like this (the field has the value already set from the code behind):


After adding an item, it should look like:

I tried to keep this example small and simple, but this mechanism could be extended for many scenarios (master-details, external datasources, custom validations, use other than the default controls to render SharePoint fields, etc).
This example is based partially on MSDN documentation and partially on things I found by looking into the SharePoint assemblies.
I put a brief explanation along with the steps needed to create a custom form with code behind here:

2. Master-detail relations between two fields in a custom form

To test, deploy the solution and in the newly created "ContentTypeCustomForms2 - ListInstance1" list, add a new item. The form should look like:
Changing a value for the "country" field, will update the content of the "town" field.

Last edited May 8, 2012 at 3:01 PM by ctapus, version 9