Hi,
Today I would like to publish Small article for How to Customize SharePoint list form using visual studio 2010.
There are two ways to customize our SharePoint 2010 list form.
1) 1st way : Here is excellent article written by ikarstein.I am always follow him update blogs and also be Big Fan
.
2) 2nd way I am describing over here:
My Requirement:
I have one Announcement List Template and displaying different type of Announcement. Something like
I.E Alert, InternalAnnouncement, Spotlight, New Release etc..
So on that time I have created different type of Content Types and that Content Types associate with Announcement List Template with different Designing Form Template.so Below approved better for me.
I have taken Empty SharePoint project (deploy as farm solution). My project name is : SP2010CustomListForm On this project I have create one Custom Site Content Type, Custom List Definition than inherited Content type to List Template.
Download Source Code Over Here.
Create Site Content Type :
Right click on project (SP2010CustomListForm) > Add new Item > Content Type > (Inherited from Item) > Okay

Create List Definition:
Right click on project (SP2010CustomListForm) > Add new Item > List Definition > Provide name to Template

I am taking Template Type is Custom List also be attach
list instance for list definition. Now go on Schema.xml of MyListDef(list
definition)

Than modify list definition schema. Find it out below line on Schema.xml
XML
<ContentTypeRef ID="0x01">
<Folder TargetName="Item" />
</ContentTypeRef>
And Replace with your Site Content Type. For Me my Site Content Type
XML
<!-- Parent ContentType: Item (0x01) -->
<ContentType ID="0x0100ca617ed5b05a4ded890902bbf86e3886"
Name="MyContentType"
Group="Custom Content Types"
Description="My Content Type"
Inherits="FALSE"
Version="0">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title"/>
<FieldRef ID="{03E7B8FC-8BD8-48D9-BB07-A9FB5F86F277}" Name="MyCustom"/>
</FieldRefs>
</ContentType>
You can see on below screenshot of MyConentType.than I have add
XmlDocuments Element (ContentType) on that content type.
What is XmlDocuments???
The XmlDocuments element contains a collection of XmlDocument elements. You can include custom information in content type definitions by adding special XML nodes. These XML nodes are represented by the XmlDocument element in the content type definition and can be accessed programmatically through the object model. A content type can include any number of XmlDocument elements. The contents of each XmlDocument element can conform to any given schema; they only need to be valid XML. Here is example for Item Content Type.
XML
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ListForm</Edit>
<New>ListForm</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
For more details see on MSDN(http://msdn.microsoft.com/en-us/library/aa543904.aspx)
So Finally MyContentType become like:

Create custom list form template :
Now we have create new form template and that associate to content type for accomplish our requirement. For that we need to add User Control on Control Template that project. So right click on
Project(SP2010CustomListForm) > Add > SharePoint Mapped Folder > Template > Control Template > OK


Than right click on ControlTemplates > Add New Item > ListFormEditTemplate.ascx Again add one more User Control (ListFormEditRender.ascx) on Control Templates and render your HTML. Here screenshot of my ListFormEditRender.ascx control.

Operation on ListFormEditTemplate.ascx : Open ListFormEditTemplate.ascx for doing register SharePoint Ribbon Toolbar below line adds on your User Control.
HTML
<%@ Register TagPrefix="wssuc" TagName="ToolBar" Src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" Src="~/_controltemplates/ToolBarButton.ascx" %>
Register ListFormEditRender.ascx control on this ascx control using like:
HTML
<%@ Register TagPrefix="myCustomForm" TagName="AddForm" Src="~/_controltemplates/ListFormEditRender.ascx" %>
The templates used for the UI in the ListViewWewPart are contained in RenderingTemplates that can be found in <SharePoint Root>\14\TEMPLATE\CONTROLTEMPLATES\DefautlTemplates.ascx. This UserControl contains 145 RenderingTemplates that are used to display fields, such as NumberField and CurrencyField, and UI for forms, such as SurveyForm or WkiEditForm. For this discussion, we are interested in the RenderingTemplate with ID ListForm.
RenderingTemplate ID is ListFormEdit. It’s should be unique if you want to use multiple.
HTML
<SharePoint:RenderingTemplate ID="ListFormEdit" runat="server">
<Template>
<span id='part1'>
<SharePoint:InformationBar ID="InformationBar1" runat="server" />
<div id="listFormToolBarTop">
<wssuc:ToolBar CssClass="ms-formtoolbar" ID="toolBarTbltop" RightButtonSeparator="&#160;"
runat="server">
<Template_RightButtons>
<SharePoint:NextPageButton ID="NextPageButton1" runat="server" />
<SharePoint:SaveButton ID="SaveButton1" runat="server" />
<SharePoint:GoBackButton ID="GoBackButton1" runat="server" />
</Template_RightButtons>
</wssuc:ToolBar>
</div>
<SharePoint:FormToolBar ID="FormToolBar1" runat="server" />
<SharePoint:ItemValidationFailedMessage ID="ItemValidationFailedMessage1" runat="server" />
<table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0"
width="100%">
<SharePoint:ChangeContentType ID="ChangeContentType1" runat="server" />
<SharePoint:FolderFormFields ID="FolderFormFields1" runat="server" />
<!-- myCustomForm ListFormEditRender.ascx render -->
<myCustomForm:AddForm runat="server" />
<!-- myCustomForm ListFormEditRender.ascx render -->
<SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server" />
<SharePoint:ApprovalStatus ID="ApprovalStatus1" runat="server" />
<SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows" runat="server" />
</table>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="ms-formline">
<img src="/_layouts/images/blank.gif" width='1' height='1' alt="" />
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px">
<tr>
<td width="100%">
<SharePoint:ItemHiddenVersion ID="ItemHiddenVersion1" runat="server" />
<SharePoint:ParentInformationField ID="ParentInformationField1" runat="server" />
<SharePoint:InitContentType ID="InitContentType1" runat="server" />
<wssuc:ToolBar CssClass="ms-formtoolbar" ID="toolBarTbl" RightButtonSeparator="&#160;"
runat="server">
<Template_Buttons>
<SharePoint:CreatedModifiedInfo ID="CreatedModifiedInfo1" runat="server" />
</Template_Buttons>
<Template_RightButtons>
<SharePoint:SaveButton ID="SaveButton2" runat="server" />
<SharePoint:GoBackButton ID="GoBackButton2" runat="server" />
</Template_RightButtons>
</wssuc:ToolBar>
</td>
</tr>
</table>
</span>
<SharePoint:AttachmentUpload ID="AttachmentUpload1" runat="server" />
</Template>
</SharePoint:RenderingTemplate>
That’s it!!! Now we need only 1 more Change.
Again Edit Schema.xml File of MyListDef(List Definition) :
Replace your
XML
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ListFormEdit</Edit>
<New>ListForm</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
RenderingTemplate ID is ListFormEdit replace on XMlDocument of Content Type.

Deployed your solution!!!!
OutPut :

Are you able to see Custom Form Tempalte??
If not than
There are two very big and not well documented issues that may present themselves when using a custom RenderingTemplate. First, you may notice the default RenderingTemplate is used rather than the custom one you have created. This is because of the Inherits attribute on the ContentType. For an as yet to be explained reason, it must be either removed or set to false so the custom RenderingTemplate will be used.
Set on your Content Type attribute Inherite to “False”
Inherits=”FALSE”
Hope Its Helps!!!