<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jimyang&#039;s blog</title>
	<atom:link href="http://vspug.com/jimyang/feed/" rel="self" type="application/rss+xml" />
	<link>http://vspug.com/jimyang</link>
	<description>Just another VSPUG - Virtual SharePoint User Group weblog</description>
	<lastBuildDate>Wed, 16 May 2007 08:16:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>My way to deploy Sharepoint Solution</title>
		<link>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/</link>
		<comments>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/#comments</comments>
		<pubDate>Wed, 16 May 2007 08:16:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[VS.NET extension for Sharepoint 2007 is a great tool to create webparts, features and site definitions. But I found it&#39;s not very not that easy to package the solution and deploy to production servers. I need to create manifest.xml and a ddf file and have to use makecab.exe tool. I don&#39;t why MS doesn&#39;t auotmatically [...]]]></description>
			<content:encoded><![CDATA[<p>VS.NET extension for Sharepoint 2007 is a great tool to create webparts, features and site definitions. But I found it&#39;s not very not that easy to package the solution and deploy to production servers. I need to create manifest.xml and a ddf file and have to use makecab.exe tool. I don&#39;t why MS doesn&#39;t auotmatically genereate in the solution.</p>
<p>And my simple way to deploy the solution is </p>
<ul>
<li>Find the setup.bat and solution folder under binDebug (usually it&#39;s generated after you build and deploy the solution in VS.NET)</li>
<li>Copy your release version dlls to&nbsp;solution folder&nbsp;</li>
<li>Open setup.bat and change &quot;TargetUrl&quot; to your production server.</li>
<li>Copy these file and folder to production</li>
<li>Run &quot;setup /i&quot;</li>
</ul>
<p>and it works great.</p>
<p>I&#39;ve also find a&nbsp;Sharepont Solution Installer tool in here:</p>
<p><a href="http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx">http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx</a></p>
<p>it sounds a&nbsp;nice tool but I didn&#39;t try it yet.&nbsp;</p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=25896" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My way to deploy Sharepoint Solution</title>
		<link>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/</link>
		<comments>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/#comments</comments>
		<pubDate>Wed, 16 May 2007 08:16:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[VS.NET extension for Sharepoint 2007 is a great tool to create webparts, features and site definitions. But I found it&#39;s not very not that easy to package the solution and deploy to production servers. I need to create manifest.xml and a ddf file and have to use makecab.exe tool. I don&#39;t why MS doesn&#39;t auotmatically [...]]]></description>
			<content:encoded><![CDATA[<p>VS.NET extension for Sharepoint 2007 is a great tool to create webparts, features and site definitions. But I found it&#39;s not very not that easy to package the solution and deploy to production servers. I need to create manifest.xml and a ddf file and have to use makecab.exe tool. I don&#39;t why MS doesn&#39;t auotmatically genereate in the solution.</p>
<p>And my simple way to deploy the solution is </p>
<ul>
<li>Find the setup.bat and solution folder under binDebug (usually it&#39;s generated after you build and deploy the solution in VS.NET)</li>
<li>Copy your release version dlls to&nbsp;solution folder&nbsp;</li>
<li>Open setup.bat and change &quot;TargetUrl&quot; to your production server.</li>
<li>Copy these file and folder to production</li>
<li>Run &quot;setup /i&quot;</li>
</ul>
<p>and it works great.</p>
<p>I&#39;ve also find a&nbsp;Sharepont Solution Installer tool in here:</p>
<p><a href="http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx">http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx</a></p>
<p>it sounds a&nbsp;nice tool but I didn&#39;t try it yet.&nbsp;</p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=25896" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2007/05/16/my-way-to-deploy-sharepoint-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update WSS 3.0 User Profile Programmatically</title>
		<link>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/</link>
		<comments>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 10:05:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[In WSS 3.0, there is a special list `User Information List&#39; for user&#39;s profile information. When a user is added to the Sharepoint site, a list item is automatically created in this list. To update the user&#39;s information in `User Information List&#39;, for instance, to update the user&#39;s photo, I am using following code and [...]]]></description>
			<content:encoded><![CDATA[<p>In WSS 3.0, there is a special list `User Information List&#39; for user&#39;s profile information. When a user is added to the Sharepoint site, a list item is automatically created in this list. To update the user&#39;s information in `User Information List&#39;, for instance, to update the user&#39;s photo, I am using following code and it works fine:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Microsoft.SharePoint.SPList list = web.Lists[&quot;User Information List&quot;];</p>
<p>Microsoft.SharePoint.SPUser u = web.SiteUsers["domain\user1"];</p>
<p>Microsoft.SharePoint.SPListItem it = list.Items.GetItemById(u.ID);</p>
<p>&nbsp;</p>
<p>it["Picture"] =&#8221;http://sharepointApp/sites/wss/photos/abc.jpg&#8221;;</p>
<p>it.Update();</p>
<p>&nbsp;</p>
<p>Also, you are able to add a custom field to user profile like this:</p>
<p>&nbsp;</p>
<p>Microsoft.SharePoint.SPList list = web.Lists[&quot;User Information List&quot;];<br />if (!list.Fields.ContainsField(&quot;Favorites&quot;))<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list.Fields.Add(&quot;Favorites&quot;, SPFieldType.Text, false);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list.Update();<br />}</p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=16631" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update WSS 3.0 User Profile Programmatically</title>
		<link>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/</link>
		<comments>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 10:05:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[In WSS 3.0, there is a special list `User Information List&#39; for user&#39;s profile information. When a user is added to the Sharepoint site, a list item is automatically created in this list. To update the user&#39;s information in `User Information List&#39;, for instance, to update the user&#39;s photo, I am using following code and [...]]]></description>
			<content:encoded><![CDATA[<p>In WSS 3.0, there is a special list `User Information List&#39; for user&#39;s profile information. When a user is added to the Sharepoint site, a list item is automatically created in this list. To update the user&#39;s information in `User Information List&#39;, for instance, to update the user&#39;s photo, I am using following code and it works fine:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Microsoft.SharePoint.SPList list = web.Lists[&quot;User Information List&quot;];</p>
<p>Microsoft.SharePoint.SPUser u = web.SiteUsers["domain\user1"];</p>
<p>Microsoft.SharePoint.SPListItem it = list.Items.GetItemById(u.ID);</p>
<p>&nbsp;</p>
<p>it["Picture"] =&#8221;http://sharepointApp/sites/wss/photos/abc.jpg&#8221;;</p>
<p>it.Update();</p>
<p>&nbsp;</p>
<p>Also, you are able to add a custom field to user profile like this:</p>
<p>&nbsp;</p>
<p>Microsoft.SharePoint.SPList list = web.Lists[&quot;User Information List&quot;];<br />if (!list.Fields.ContainsField(&quot;Favorites&quot;))<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list.Fields.Add(&quot;Favorites&quot;, SPFieldType.Text, false);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list.Update();<br />}</p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=16631" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMWare Server released and it&#039;s free, too</title>
		<link>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/</link>
		<comments>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/#comments</comments>
		<pubDate>Fri, 14 Jul 2006 20:09:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[VMWare Server was released after serveral months beta. You can free register and download it from here.&#160;It looks have more features than MS Virtual Server R2, which is also free. And from many comparison articles in Internet, it should have better performance than Virtual Server.

]]></description>
			<content:encoded><![CDATA[<p><font >VMWare Server was released after serveral months beta. You can free register and download it from </font><a href="http://www.vmware.com/download/server/"><font >here</font></a><font >.&nbsp;It looks have more features than MS Virtual Server R2, which is also free. And from many comparison articles in Internet, it should have better performance than Virtual Server.</font></p>
<p><img src="/aggbug.aspx?PostID=9175" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMWare Server released and it&#039;s free, too</title>
		<link>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/</link>
		<comments>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/#comments</comments>
		<pubDate>Fri, 14 Jul 2006 20:09:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[VMWare Server was released after serveral months beta. You can free register and download it from here.&#160;It looks have more features than MS Virtual Server R2, which is also free. And from many comparison articles in Internet, it should have better performance than Virtual Server.

]]></description>
			<content:encoded><![CDATA[<p><font >VMWare Server was released after serveral months beta. You can free register and download it from </font><a href="http://www.vmware.com/download/server/"><font >here</font></a><font >.&nbsp;It looks have more features than MS Virtual Server R2, which is also free. And from many comparison articles in Internet, it should have better performance than Virtual Server.</font></p>
<p><img src="/aggbug.aspx?PostID=9175" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/14/vmware-server-released-and-it-s-free-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Topic Assistant is not in MOSS 2007</title>
		<link>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/</link>
		<comments>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/#comments</comments>
		<pubDate>Thu, 13 Jul 2006 20:48:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I noticed the Topic Assistant&#160;is not in MOSS 2007 any more. In SPS 2003, you can set up a training set in an area, and the Topic Assistant will automatically categorize and assocaite the portal content&#160;to the area. Although I know there are not too many people really use this feature but it seems to [...]]]></description>
			<content:encoded><![CDATA[<p><font >I noticed the Topic Assistant&nbsp;is not in MOSS 2007 any more. In SPS 2003, you can set up a training set in an area, and the Topic Assistant will automatically categorize and assocaite the portal content&nbsp;to the area. Although I know there are not too many people really use this feature but it seems to be a helpful tool when you want to organize massive content&nbsp;to the&nbsp;company&#39;s taxonomies.</font></p>
<p><font >Don&#39;t know why MS remove it instead of providing an improved equivalent tool.</font></p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=9137" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Topic Assistant is not in MOSS 2007</title>
		<link>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/</link>
		<comments>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/#comments</comments>
		<pubDate>Thu, 13 Jul 2006 20:48:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[I noticed the Topic Assistant&#160;is not in MOSS 2007 any more. In SPS 2003, you can set up a training set in an area, and the Topic Assistant will automatically categorize and assocaite the portal content&#160;to the area. Although I know there are not too many people really use this feature but it seems to [...]]]></description>
			<content:encoded><![CDATA[<p><font >I noticed the Topic Assistant&nbsp;is not in MOSS 2007 any more. In SPS 2003, you can set up a training set in an area, and the Topic Assistant will automatically categorize and assocaite the portal content&nbsp;to the area. Although I know there are not too many people really use this feature but it seems to be a helpful tool when you want to organize massive content&nbsp;to the&nbsp;company&#39;s taxonomies.</font></p>
<p><font >Don&#39;t know why MS remove it instead of providing an improved equivalent tool.</font></p>
<p>&nbsp;</p>
<p><img src="/aggbug.aspx?PostID=9137" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/13/topic-assistant-is-not-in-moss-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create custom field type in WSS V3</title>
		<link>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/</link>
		<comments>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/#comments</comments>
		<pubDate>Mon, 10 Jul 2006 09:53:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[WSS v3 supports creating custom field type with OM, and you have total control on its internal data storage, editing and display. I have tested it today by creating a custom phone number field with 3 sub-fields: country code, area code and phone number. 
1. Create a ascx control and its code behind for editing
In [...]]]></description>
			<content:encoded><![CDATA[<p><font >WSS v3 supports creating custom field type with OM, and you have total control on its internal data storage, editing and display. I have tested it today by creating a custom phone number field with 3 sub-fields: country code, area code and phone number. </font></p>
<p><strong><font >1. Create a ascx control and its code behind for editing</font></strong></p>
<p><font >In order to make the custom field type editable in form view, we need to custom rendering user control for this new field type. At first, we need to create an ascx file with a Sharepoint RenderingTemplate control on it. See the code below.</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;%@ Control Language=&quot;C#&quot; %&gt;<br />&lt;%@ Assembly Name=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;<br />&lt;%@ Register Tagprefix=&quot;SharePoint&quot; Namespace=&quot;Microsoft.SharePoint.WebControls&quot; Assembly=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;SharePoint:RenderingTemplate ID=&quot;PhoneNumberFieldRendering&quot; runat=&quot;server&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Template&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&lt;asp:TextBox ID=&quot;txtCountryCode&quot; runat=&quot;server&quot; MaxLength=&quot;3&quot; Size=&quot;3&quot;&gt;&lt;/asp:TextBox&gt;(&lt;asp:TextBox ID=&quot;txtAreaCode&quot; runat=&quot;server&quot; MaxLength=&quot;3&quot; Size=&quot;3&quot;&gt;&lt;/asp:TextBox&gt;)&lt;asp:TextBox ID=&quot;txtNumber&quot; runat=&quot;server&quot; MaxLength=&quot;8&quot; Size=&quot;8&quot;&gt;&lt;/asp:TextBox&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Template&gt;<br />&lt;/SharePoint:RenderingTemplate&gt;</font></p>
<p><font >Then we need to implement its code behind class. The class must derives BaseFieldControl and overrides the property Value to set the three fields of a phone number into three segments in SPFieldMultiColumnValue object.</font></p>
<p><font >&nbsp;&nbsp;</font><font face="Courier New" color="#a9a9a9" size="2">&nbsp; public class PhoneNumberFieldControl : Microsoft.SharePoint.WebControls.BaseFieldControl<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtCountryCode;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtAreaCode;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtNumberCode;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override string DefaultTemplateName<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &quot;PhoneNumberFieldControl&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override object Value<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = new Microsoft.SharePoint.SPFieldMultiColumnValue(3);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[0] = txtCountryCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[1] = txtAreaCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[2] = txtNumberCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return phoneNumberValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = value as Microsoft.SharePoint.SPFieldMultiColumnValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Text = phoneNumberValue[0];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.Text = phoneNumberValue[1];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.Text = phoneNumberValue[2];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void Focus()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Focus();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override void CreateChildControls()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (Field == null) return;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.CreateChildControls();</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtCountryCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtCountryCode == null) throw new NullReferenceException(&quot;txtCountryCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.ToolTip = Field.Title + &quot; Country Code&quot;;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtAreaCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtAreaCode == null) throw new NullReferenceException(&quot;txtAreaCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.ToolTip = Field.Title + &quot; Area Code&quot;;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtNumberCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtNumberCode == null) throw new NullReferenceException(&quot;txtNumberCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.ToolTip = Field.Title + &quot; Phone Number&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.New)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Text = Field.GetCustomProperty(&quot;DefaultCountryCode&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.Text = Field.GetCustomProperty(&quot;DefaultAreaCode&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.Text = Field.GetCustomProperty(&quot;DefaultNumber&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</font></p>
<p><font ><strong>2. Create a custom field type class</strong></font></p>
<p><font >The custom field type must inherit the base class SPField. In my test, I wrote following class derives SPFieldMultiColumn which is a subclass of SPField but supports multiple sub-columns. GetValidatedString overridden method checks the input object value and return its string value if it&#39;s correct. GetFieldValue method is to create a SPFieldMultiColumnValue object by the input string. FieldRenderingControl property returns the user control we created in step 1.</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">public class PhoneNumberField : Microsoft.SharePoint.SPFieldMultiColumn<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public PhoneNumberField(Microsoft.SharePoint.SPFieldCollection fields, string fieldName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : base(fields, fieldName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public PhoneNumberField(Microsoft.SharePoint.SPFieldCollection fields, string typeName, string displayName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : base(fields, typeName, displayName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override string GetValidatedString(object value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = value as Microsoft.SharePoint.SPFieldMultiColumnValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (phoneNumberValue == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return String.Empty;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(String.IsNullOrEmpty(phoneNumberValue[0]) || String.IsNullOrEmpty(phoneNumberValue[1]) || String.IsNullOrEmpty(phoneNumberValue[2]))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Microsoft.SharePoint.SPFieldValidationException(Microsoft.SharePoint.SPResource.GetString(Microsoft.SharePoint.Strings.MissingRequiredField));</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return value.ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override object GetFieldValue(string value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (String.IsNullOrEmpty(value))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = new Microsoft.SharePoint.SPFieldMultiColumnValue(value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return phoneNumberValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.WebControls.BaseFieldControl phoneNumberFieldControl = new PhoneNumberFieldControl();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return base.FieldRenderingControl;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</font></p>
<p><font ><strong>3.&nbsp;Create custom Field Type Definition</strong></font></p>
<p><font >The custom type must include a custom field type definition. It&#39;s an XML file with file name fldtypes_*.xml. I named my phone number field definition file as fldtypes_phonenumber.xml. The detail schema is in </font><a href="http://msdn2.microsoft.com/en-us/library/ms415141.aspx"><font >http://msdn2.microsoft.com/en-us/library/ms415141.aspx</font></a></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;FieldTypes&gt;<br />&nbsp; &lt;FieldType&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeName&quot;&gt;PhoneNumber&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ParentType&quot;&gt;MultiColumn&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeDisplayName&quot;&gt;Phone Number&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeShortDescription&quot;&gt;Phone Number&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;UserCreatable&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInListCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInSurveyCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInDocumentLibraryCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInColumnTemplateCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;FieldTypeClass&quot;&gt;WSSFieldDemo.PhoneNumberField,WSSFieldDemo,Version=1.0.0.0,Culture=neutral,PublicKeyToken=5cca1e4ab4efce28&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;PropertySchema&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Fields&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultCountryCode&quot; DisplayName=&quot;Default Country Code&quot; MaxLength=&quot;3&quot; DisplaySize=&quot;3&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;1&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultAreaCode&quot; DisplayName=&quot;Default Area Code&quot; MaxLength=&quot;3&quot; DisplaySize=&quot;3&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;416&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultNumber&quot; DisplayName=&quot;Default Phone Number&quot; MaxLength=&quot;8&quot; DisplaySize=&quot;8&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;5325554&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Fields&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/PropertySchema&gt;<br />&nbsp;&nbsp;&nbsp; &lt;RenderPattern Name=&quot;DisplayPattern&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Switch&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Expr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Expr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Case Value=&quot;&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[+]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;0&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[(]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;1&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[)]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;2&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Switch&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/RenderPattern&gt;<br />&nbsp; &lt;/FieldType&gt;<br />&lt;/FieldTypes&gt;</font></p>
<p><font ><strong>4.&nbsp;Deployment</strong></font></p>
<p><font >The final step is to deploy the assembly, user control and the field definition xml. It includes following steps:</font></p>
<p><font >1.&nbsp;Build the solution and sign the assembly<br />2.&nbsp;Put the assembly into GAC<br />3.&nbsp;Copy the user control to program files&#8230;web server extensions12	emplatecontroltemplates<br />4.&nbsp;Copy fldtypes_phonenumber.xml to program files&#8230;web server extensions12	emplatexml<br />5.&nbsp;iisreset.<br /></font></p>
<p><img src="/aggbug.aspx?PostID=9025" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create custom field type in WSS V3</title>
		<link>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/</link>
		<comments>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/#comments</comments>
		<pubDate>Mon, 10 Jul 2006 09:53:00 +0000</pubDate>
		<dc:creator>unclaimed blog</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[WSS v3 supports creating custom field type with OM, and you have total control on its internal data storage, editing and display. I have tested it today by creating a custom phone number field with 3 sub-fields: country code, area code and phone number. 
1. Create a ascx control and its code behind for editing
In [...]]]></description>
			<content:encoded><![CDATA[<p><font >WSS v3 supports creating custom field type with OM, and you have total control on its internal data storage, editing and display. I have tested it today by creating a custom phone number field with 3 sub-fields: country code, area code and phone number. </font></p>
<p><strong><font >1. Create a ascx control and its code behind for editing</font></strong></p>
<p><font >In order to make the custom field type editable in form view, we need to custom rendering user control for this new field type. At first, we need to create an ascx file with a Sharepoint RenderingTemplate control on it. See the code below.</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;%@ Control Language=&quot;C#&quot; %&gt;<br />&lt;%@ Assembly Name=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;<br />&lt;%@ Register Tagprefix=&quot;SharePoint&quot; Namespace=&quot;Microsoft.SharePoint.WebControls&quot; Assembly=&quot;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %&gt;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;SharePoint:RenderingTemplate ID=&quot;PhoneNumberFieldRendering&quot; runat=&quot;server&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Template&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +&lt;asp:TextBox ID=&quot;txtCountryCode&quot; runat=&quot;server&quot; MaxLength=&quot;3&quot; Size=&quot;3&quot;&gt;&lt;/asp:TextBox&gt;(&lt;asp:TextBox ID=&quot;txtAreaCode&quot; runat=&quot;server&quot; MaxLength=&quot;3&quot; Size=&quot;3&quot;&gt;&lt;/asp:TextBox&gt;)&lt;asp:TextBox ID=&quot;txtNumber&quot; runat=&quot;server&quot; MaxLength=&quot;8&quot; Size=&quot;8&quot;&gt;&lt;/asp:TextBox&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/Template&gt;<br />&lt;/SharePoint:RenderingTemplate&gt;</font></p>
<p><font >Then we need to implement its code behind class. The class must derives BaseFieldControl and overrides the property Value to set the three fields of a phone number into three segments in SPFieldMultiColumnValue object.</font></p>
<p><font >&nbsp;&nbsp;</font><font face="Courier New" color="#a9a9a9" size="2">&nbsp; public class PhoneNumberFieldControl : Microsoft.SharePoint.WebControls.BaseFieldControl<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtCountryCode;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtAreaCode;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected System.Web.UI.WebControls.TextBox txtNumberCode;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override string DefaultTemplateName<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &quot;PhoneNumberFieldControl&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override object Value<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = new Microsoft.SharePoint.SPFieldMultiColumnValue(3);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[0] = txtCountryCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[1] = txtAreaCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; phoneNumberValue[2] = txtNumberCode.Text.Trim();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return phoneNumberValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = value as Microsoft.SharePoint.SPFieldMultiColumnValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Text = phoneNumberValue[0];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.Text = phoneNumberValue[1];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.Text = phoneNumberValue[2];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void Focus()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Focus();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override void CreateChildControls()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (Field == null) return;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.CreateChildControls();</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtCountryCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtCountryCode == null) throw new NullReferenceException(&quot;txtCountryCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.ToolTip = Field.Title + &quot; Country Code&quot;;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtAreaCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtAreaCode == null) throw new NullReferenceException(&quot;txtAreaCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.ToolTip = Field.Title + &quot; Area Code&quot;;</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode = (System.Web.UI.WebControls.TextBox)FindControl(&quot;txtNumberCode&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (txtNumberCode == null) throw new NullReferenceException(&quot;txtNumberCode is null. Corrupted PhoneNumberFieldControl.ascx file.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.TabIndex = TabIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.CssClass = CssClass;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.ToolTip = Field.Title + &quot; Phone Number&quot;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.New)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtCountryCode.Text = Field.GetCustomProperty(&quot;DefaultCountryCode&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtAreaCode.Text = Field.GetCustomProperty(&quot;DefaultAreaCode&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtNumberCode.Text = Field.GetCustomProperty(&quot;DefaultNumber&quot;).ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</font></p>
<p><font ><strong>2. Create a custom field type class</strong></font></p>
<p><font >The custom field type must inherit the base class SPField. In my test, I wrote following class derives SPFieldMultiColumn which is a subclass of SPField but supports multiple sub-columns. GetValidatedString overridden method checks the input object value and return its string value if it&#39;s correct. GetFieldValue method is to create a SPFieldMultiColumnValue object by the input string. FieldRenderingControl property returns the user control we created in step 1.</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">public class PhoneNumberField : Microsoft.SharePoint.SPFieldMultiColumn<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public PhoneNumberField(Microsoft.SharePoint.SPFieldCollection fields, string fieldName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : base(fields, fieldName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public PhoneNumberField(Microsoft.SharePoint.SPFieldCollection fields, string typeName, string displayName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : base(fields, typeName, displayName)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override string GetValidatedString(object value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = value as Microsoft.SharePoint.SPFieldMultiColumnValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (phoneNumberValue == null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return String.Empty;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(String.IsNullOrEmpty(phoneNumberValue[0]) || String.IsNullOrEmpty(phoneNumberValue[1]) || String.IsNullOrEmpty(phoneNumberValue[2]))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Microsoft.SharePoint.SPFieldValidationException(Microsoft.SharePoint.SPResource.GetString(Microsoft.SharePoint.Strings.MissingRequiredField));</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return value.ToString();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override object GetFieldValue(string value)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (String.IsNullOrEmpty(value))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.SPFieldMultiColumnValue phoneNumberValue = new Microsoft.SharePoint.SPFieldMultiColumnValue(value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return phoneNumberValue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.SharePoint.WebControls.BaseFieldControl phoneNumberFieldControl = new PhoneNumberFieldControl();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return base.FieldRenderingControl;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</font></p>
<p><font ><strong>3.&nbsp;Create custom Field Type Definition</strong></font></p>
<p><font >The custom type must include a custom field type definition. It&#39;s an XML file with file name fldtypes_*.xml. I named my phone number field definition file as fldtypes_phonenumber.xml. The detail schema is in </font><a href="http://msdn2.microsoft.com/en-us/library/ms415141.aspx"><font >http://msdn2.microsoft.com/en-us/library/ms415141.aspx</font></a></p>
<p><font face="Courier New" color="#a9a9a9" size="2">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;FieldTypes&gt;<br />&nbsp; &lt;FieldType&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeName&quot;&gt;PhoneNumber&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ParentType&quot;&gt;MultiColumn&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeDisplayName&quot;&gt;Phone Number&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;TypeShortDescription&quot;&gt;Phone Number&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;UserCreatable&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInListCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInSurveyCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInDocumentLibraryCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;ShowInColumnTemplateCreate&quot;&gt;TRUE&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;FieldTypeClass&quot;&gt;WSSFieldDemo.PhoneNumberField,WSSFieldDemo,Version=1.0.0.0,Culture=neutral,PublicKeyToken=5cca1e4ab4efce28&lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;PropertySchema&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Fields&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultCountryCode&quot; DisplayName=&quot;Default Country Code&quot; MaxLength=&quot;3&quot; DisplaySize=&quot;3&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;1&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultAreaCode&quot; DisplayName=&quot;Default Area Code&quot; MaxLength=&quot;3&quot; DisplaySize=&quot;3&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;416&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Field Name=&quot;DefaultNumber&quot; DisplayName=&quot;Default Phone Number&quot; MaxLength=&quot;8&quot; DisplaySize=&quot;8&quot; Type=&quot;Text&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;5325554&lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Fields&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/PropertySchema&gt;<br />&nbsp;&nbsp;&nbsp; &lt;RenderPattern Name=&quot;DisplayPattern&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Switch&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Expr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Expr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Case Value=&quot;&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[+]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;0&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[(]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;1&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HTML&gt;&lt;![CDATA[)]]&gt;&lt;/HTML&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Column SubColumnNumber=&quot;2&quot; HTMLEncode=&quot;TRUE&quot; /&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Default&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Switch&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/RenderPattern&gt;<br />&nbsp; &lt;/FieldType&gt;<br />&lt;/FieldTypes&gt;</font></p>
<p><font ><strong>4.&nbsp;Deployment</strong></font></p>
<p><font >The final step is to deploy the assembly, user control and the field definition xml. It includes following steps:</font></p>
<p><font >1.&nbsp;Build the solution and sign the assembly<br />2.&nbsp;Put the assembly into GAC<br />3.&nbsp;Copy the user control to program files&#8230;web server extensions12	emplatecontroltemplates<br />4.&nbsp;Copy fldtypes_phonenumber.xml to program files&#8230;web server extensions12	emplatexml<br />5.&nbsp;iisreset.<br /></font></p>
<p><img src="/aggbug.aspx?PostID=9025" width="1" height="1" alt="  " /></p>
]]></content:encoded>
			<wfw:commentRss>http://vspug.com/jimyang/2006/07/10/create-custom-field-type-in-wss-v3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
