<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1804865242850018128</id><updated>2012-02-01T13:17:12.577+01:00</updated><category term='Office 365'/><category term='Bug and Error'/><category term='Dot Net Framework'/><category term='C# Tips'/><category term='miscellaneous'/><category term='Asp.Net'/><category term='Deployment'/><category term='SharePoint'/><category term='Ribbon UI'/><category term='Receiver'/><category term='SharePoint 2010'/><category term='Ajax'/><category term='Configuration'/><category term='Report RDLC'/><category term='Master Page'/><category term='PowerShell'/><category term='Taxonomy'/><category term='WebPart'/><category term='Programming - General'/><category term='Programming - Tips and Tricks'/><category term='SharePoint Designer'/><category term='Linq to SharePoint'/><category term='Branding'/><category term='Client OM'/><category term='Enterprise Metadata Magement (EMM)'/><category term='JavaScript'/><category term='Test Driven Development (TDD)'/><category term='Email Marketing and Management'/><category term='Operating System'/><category term='WPF'/><category term='Architecture and Design Pattern'/><category term='Backup Restore'/><category term='Cloud'/><title type='text'>Sohel's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default?start-index=101&amp;max-results=100'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>142</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-7023494878158127559</id><published>2011-11-20T13:45:00.000+01:00</published><updated>2011-11-20T13:56:13.211+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Configuration'/><title type='text'>SharePoint 2010: Configure Kerberos Authentication</title><content type='html'>&lt;p&gt;SharePoint 2010 supports two authentication mode: Classic mode and Claims based. Today I’m going to explain how to configure Kerberos authentication for an web application with classic mode Authentication. I’ll try to explain how to configure Kerberos for an web application with Claims based authentication later.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 1:&amp;#160; Create/Configure Web Application&lt;/h4&gt;  &lt;p&gt;In this step you need to create an web application with required configurations. However, you can convert an existing web application to use Kerberos authentication if the web application app pool user is a domain user. But as mentioned already, &lt;font color="#ff0000"&gt;the configuration explained in this post applies for an web application with Classic Mode Authentication&lt;/font&gt;.&lt;/p&gt;  &lt;h5&gt;&lt;u&gt;Create a new web application&lt;/u&gt;&lt;/h5&gt;  &lt;p&gt;In creating new web application for using Kerberos Authentication you need to consider the following options:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Use classic mode Authentication as shown below (&lt;font color="#ff0000"&gt;You can use Claims Based Authentication but then the steps described in this post might not work. For Claims Based Authentication you need different sets of configuration&lt;/font&gt;):       &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-AdLmvDPPDYk/Tsj4Cob2JHI/AAAAAAAAAyA/NwxDpVzxlY0/s1600-h/image15.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-IWDrUekPVBk/Tsj4Dvuvs8I/AAAAAAAAAyI/iCuz-AmMCtE/image_thumb7.png?imgmax=800" width="481" height="102" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 1: Create site with ‘Classic Mode Authentication’        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Use Negotiate (Kerberos) as Authentication Provider in ‘Create Web Application’ page as shown below:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-CFzzA6JmNF8/Tsj4ECsH-aI/AAAAAAAAAyQ/9CaOaW0iEO8/s1600-h/image11.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-1nixwtrkP1E/Tsj4FJEz7cI/AAAAAAAAAyY/xv6lQ0N5JeE/image_thumb5.png?imgmax=800" width="557" height="247" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 2: Create site with Negotiate (Kerberos) Authentication provider selected.        &lt;br /&gt;&lt;/strong&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Use domain username for app-pool account. Don’t use Predefined (like Network Service, Local System etc) user account. This is important to use domain user name as you will configure Kerberos against this app-pool username.      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-YBqOWQvwTQs/Tsj4GSvyIvI/AAAAAAAAAyg/pVBCeZlODN8/s1600-h/image19.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-eNHv40zhCro/Tsj4G05opSI/AAAAAAAAAyo/mr6VjbA3HS4/image_thumb9.png?imgmax=800" width="568" height="258" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 3: User domain user name for App-pool account.&lt;/strong&gt;       &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;One recommendation&lt;/em&gt;. Make the site url to be Fully Qualified Domain Name. For example, my server name was sohel-server and domain name was sohel.com. I’ve modified my full site name from default &lt;a href="http://sohel-server:5000"&gt;http://sohel-server:5000&lt;/a&gt; to &lt;a href="http://sohel-server.sohel.com:5000"&gt;http://sohel-server.sohel.com:5000&lt;/a&gt;. This will help you identifying if the Only Kerberos is used for authentication instead of NTLM.       &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Configure an existing web application&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you have an existing web application that you want to move to Kerberos from NTLM you need to make sure your site meets the following criterion:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The web application uses a domain user in application pool account instead of predefined account like Network Service, Local System. If your web application doesn’t use domain user then you can create a new web application with domain user name as application pool account. Changing the application pool account might make your web application malfunctioning. &lt;/li&gt;    &lt;li&gt;If you existing web application uses Classic Mode Authentication then configuration in this post should work. However, if you are using Claims based Authentication then you need to configure Security Token Service (STS) which in not mentioned in this post. If you are using Classic Mode, then you can continue this post as this post describes Kerberos for an web application with Classic Mode Authentication. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you meet the above mentioned criterion, then you can change the authentication of the site to Kerberos. To change the Authentication Provider to Kerberos, navigate to Central Admin site then click “Application Management” =&amp;gt; Manage Web Applications =&amp;gt; Select your web application =&amp;gt; Click Authentication Provider from ribbon button as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-bw1Joi6tceU/Tsj4Hg9Zp5I/AAAAAAAAAyw/h_tyGa_qIFk/s1600-h/image23.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-4mB7M1Bisc8/Tsj4IBzpQII/AAAAAAAAAy0/9I00a4_9sk0/image_thumb11.png?imgmax=800" width="510" height="144" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Change Authentication Provider     &lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the Authentication provider windows click on the zone you want to configure the Kerberos Authentication. Then you will be shown ‘Edit Authentication’ window. If your web application is using NTLM you can change the Authentication to Kerberos as shown below:&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-uK-MmjU45Fw/Tsj4Iv3yMHI/AAAAAAAAAy8/ow9KD7NPnBY/s1600-h/image27.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-1PuXADHzt9A/Tsj4Jdv910I/AAAAAAAAAzE/elixlRPeK4U/image_thumb13.png?imgmax=800" width="474" height="248" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 5: Change NTLM to Kerberos      &lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When you change the authentication type from NTLM to Kerberos you will be prompted with message saying “” as shown below. You don’t need to worry, we’ll configure other settings to use Kerberos. So just click ok button when the message appears and then save the settings.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-SO8CfBv1cYg/Tsj4Jwo8fKI/AAAAAAAAAzQ/gzJHS-Z3DXE/s1600-h/image31.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-zG6LcTCUZS8/Tsj4K3JVRmI/AAAAAAAAAzY/7nLJu9Am9ew/image_thumb15.png?imgmax=800" width="400" height="169" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 6: Warning appears during Authentication changes from NTLM to Kerberos &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 2: Configure Service Principal Name (SPN) in Active Directory&lt;/h4&gt;  &lt;p&gt;So your web application is configured for Kerberos Authentication but you need to configure Service Principal Name (SPN). Simply SPN is an unique identifier for each service (HTTP, SQL, AD etc) running in the server. An SPN is a combination of service name, host name and port name. The original format for SPN is &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;lt;Service Name&amp;gt;/&amp;lt;DNS Host&amp;gt;:Port&lt;/strong&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To know more about SPN, you can follow the link: &lt;a title="http://technet.microsoft.com/en-us/library/cc961723.aspx" href="http://technet.microsoft.com/en-us/library/cc961723.aspx"&gt;http://technet.microsoft.com/en-us/library/cc961723.aspx&lt;/a&gt;. For our web application we need to create SPN. The SPN format for our web application is as shown below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTTP/&amp;lt;DNS Host Name&amp;gt;:Port &lt;/li&gt;    &lt;li&gt;HTTP/&amp;lt;DNS FQDN&amp;gt;:Port &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In my case the SPN are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTTP/sohel-server:5000 &lt;/li&gt;    &lt;li&gt;HTTP/sohel-server.sohel.com/5000 &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;However, if you are using any port other than 80, you need to add four SPNs (two for 80 port and two for your non-80 web application port). &lt;/font&gt;&lt;font color="#ff0000"&gt;Whether you use Kerberos for 80 port, you need to add SPNs for default port&lt;/font&gt;. &lt;font color="#ff0000"&gt;So though I’m configuring Kerberos for HTTP port 5000, I need to configure Kerberos for 80 port also&lt;/font&gt;. The following SPNs are need to configured for my example.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTTP/sohel-server &lt;/li&gt;    &lt;li&gt;HTTP/sohel-server.sohel.com &lt;/li&gt;    &lt;li&gt;HTTP/sohel-server:5000 &lt;/li&gt;    &lt;li&gt;HTTP/sohel-server.sohel.com:5000 &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;How to set SPN?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Make sure you installed ‘Active Directory Lightweight Directory Services’ from Server Role to get the ADSI Edit UI for editing SPN values. You can add the&amp;#160; ‘Active Directory Lightweight Directory Services’ from Server Manager =&amp;gt; Add Roles&amp;#160; as shown below:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/-RGW7Kihm--s/Tsj4Ljmf-jI/AAAAAAAAAzc/gmFKiE1MTe0/s1600-h/image43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-4m8AUAAjEVk/Tsj4MVKcysI/AAAAAAAAAzo/SLGfWjuhGDI/image_thumb21.png?imgmax=800" width="787" height="580" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 7: Install ‘Active Directory Lightweight Directory Services’ from ‘Add Server Role’        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;To setup SPN, Run the command “adsiedit.msc” in either command prompt or from Run. You will get the ADSI Edit window. &lt;/li&gt;    &lt;li&gt;In ADSI Edit window, expand the ‘Default naming context’ and expand CN=Users and find the user you used for application pool in web application. &lt;/li&gt;    &lt;li&gt;Right click on the user entry CN=UserName and select properties window. Then find the property ‘servicePrincipalName’ and click edit as shown below:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-IKfmb64Szsc/Tsj4NZACZRI/AAAAAAAAAzs/tFXxhmyj03A/s1600-h/image35.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-tp713tVZuw4/Tsj4N8a8rNI/AAAAAAAAAz0/D3ynuJMla7M/image_thumb17.png?imgmax=800" width="416" height="453" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 8: Set SPN through servicePrincipalName        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Finally add the SPNs in the edit window as shown below:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-qMwxClHdb8Q/Tsj4Obo-5UI/AAAAAAAAA0A/LYQ8BPA0w4E/s1600-h/image39.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-Idyg1iuQQi0/Tsj4PGfc4xI/AAAAAAAAA0I/I6x-53iRp4I/image_thumb19.png?imgmax=800" width="370" height="384" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 9: Add SPN values as value of attribute ‘servicePrincipalName’.        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Press OK and then apply to close the dialog. &lt;/li&gt; &lt;/ol&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Step 3: Enable delegation&lt;/h4&gt;  &lt;p&gt;In some cases you may need to enable delegation of credentials. To enable delegation, open the Active Directory users and Computers from ‘Administrative Tools’ menu. Find the user used in Application pool under ‘Users’ node. Right click on the user and click Properties to get the properties window. Then in the properties window go to ‘Delegation’ tab and select ‘Trust this user for…’ as shown below:    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-ZDeUvNDkboM/Tsj4QInmtVI/AAAAAAAAA0M/khyLgS_UXug/s1600-h/image63.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-qq1bZWIBhhE/Tsj4Q2bpY3I/AAAAAAAAA0U/U5FQNgKZ3gg/image_thumb30.png?imgmax=800" width="424" height="531" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 10: Enable delegation &lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Step 4: Configure Internet Explorer&lt;/h4&gt;  &lt;p&gt;Finally you need to configure Internet Explorer (IE) to use current windows user to access the SharePoint site. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Go to Tool =&amp;gt; Internet Options. Then select ‘Local Intranet’ and click &lt;strong&gt;Sites&lt;/strong&gt; as shown below:       &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-JX7mCmIwVQM/Tsj4RSnaExI/AAAAAAAAA0c/nLxfp0MVC7U/s1600-h/image51.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-IsdWqfCbKSY/Tsj4SXh0MlI/AAAAAAAAA0o/GmmamIg1Dcw/image_thumb24.png?imgmax=800" width="421" height="530" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 11: Setup IE for adding the SharePoint site to local Intranet        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;After ‘Local Intranet’ dialog select ‘Advanced’ and then you’ll find the way to add sites to local intranet. Add ‘*.yourdomain’ in the local intranet zone as shown below:      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-mFGMUrHHuHs/Tsj4TBK8O7I/AAAAAAAAA0s/oWwRQWoIG7U/s1600-h/image55.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-h3-s4EhdSJk/Tsj4TiHbAxI/AAAAAAAAA04/iw0FN9ish9w/image_thumb26.png?imgmax=800" width="386" height="336" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 12: Adding my domain (sohel.com) to local intranet.        &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Now close the Internet Options dialog. Then open the ‘Internet Options’ dialog from Tools =&amp;gt; Internet Options. Then go to Security tab and select ‘Local Intranet’ and select ‘Custom Level’. Then At the end of the ‘Security settings’ window, select ‘Automatic login only in Intranet zone’ as shown below:      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/-_e6b6q-F_Lk/Tsj4UbioGAI/AAAAAAAAA1A/xEq4KZc0rKg/s1600-h/image59.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-Mzq34IdP4T8/Tsj4VjDRS0I/AAAAAAAAA1I/57KPw8mh_3I/image_thumb28.png?imgmax=800" width="419" height="475" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 13: Enable automatic login for Intranet zone&lt;/strong&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;Configuring Kerberos authentication may depends on many factors. So I can’t guarantee than each and every steps described here will work for everybody. But the overall sets of configurations are same. You need to configure SharePoint site, You need to configure SPN, You need to enable delegation (if required), you n need to configure Internet Explorer.&amp;#160; You can get elaborate description of configuring Kerberos Authentication with SharePoint 2010 from the link: &lt;a title="http://www.microsoft.com/download/en/details.aspx?id=23176" href="http://www.microsoft.com/download/en/details.aspx?id=23176"&gt;http://www.microsoft.com/download/en/details.aspx?id=23176&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-7023494878158127559?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/7023494878158127559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/11/sharepoint-2010-supports-two.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7023494878158127559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7023494878158127559'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/11/sharepoint-2010-supports-two.html' title='SharePoint 2010: Configure Kerberos Authentication'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-IWDrUekPVBk/Tsj4Dvuvs8I/AAAAAAAAAyI/iCuz-AmMCtE/s72-c/image_thumb7.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6867997904446044289</id><published>2011-10-09T07:40:00.001+02:00</published><updated>2011-10-09T07:41:37.235+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Client OM'/><title type='text'>SharePoint 2010: Get  Full or Relative Url of web using EcmaScript</title><content type='html'>&lt;p&gt;Sometimes from client side, you need to know the current web url. And for this little information you don’t want to call EcmaScript’s load function to get information from server side. Actually the information can be found without any server call. You can access the information from ClientContext as shown below.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; context = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SP.ClientContext();&lt;br /&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; relativeWebUrl = context.get_url();&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Remember the get_url method will only return relative url of the site. As shown in the following table:&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="795"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;th valign="top" width="200"&gt;Site Collection Url&lt;/th&gt;

      &lt;th valign="top" width="200"&gt;Site Url&lt;/th&gt;

      &lt;th valign="top" width="393"&gt;context.get_url() response&lt;/th&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com"&gt;http://mysite.com&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com"&gt;http://mysite.com&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="393"&gt;/&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com"&gt;http://mysite.com&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com/site1"&gt;http://mysite.com/site1&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="393"&gt;/site1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com/sites"&gt;http://mysite.com/sites&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;&lt;a href="http://mysite.com/sites/site1"&gt;http://mysite.com/sites/site1&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="393"&gt;/sites/site&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;So if you need to know the full url of the site you can do so easily with the following script:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; getFullWebUrl() {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; context = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SP.ClientContext();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; relativeWebUrl = context.get_url();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; fullWebUrl = window.location.protocol + &lt;span style="color: #006080"&gt;'//'&lt;/span&gt; + window.location.host + relativeWebUrl ;&lt;br /&gt;    alert(fullWebUrl);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6867997904446044289?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6867997904446044289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/10/sharepoint-2010-get-webs-full-or.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6867997904446044289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6867997904446044289'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/10/sharepoint-2010-get-webs-full-or.html' title='SharePoint 2010: Get  Full or Relative Url of web using EcmaScript'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-4490134441062525723</id><published>2011-09-17T10:18:00.001+02:00</published><updated>2011-09-17T10:18:51.492+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint 2010: Access WCF Service with jQuery</title><content type='html'>&lt;p&gt;In one of my &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-create-custom-wcf.html" target="_blank"&gt;earlier post&lt;/a&gt; I described how to develop a custom WCF service. Today I’ll cover how you can invoke the SharePoint WCF Service from jQuery. In my last post I described to develop a SOAP web service but for using WCF service from jQuery I’m going to use REST web service. For the list of service types and factories supported in SharePoint you can visit the link &lt;a href="http://msdn.microsoft.com/en-us/library/ff521586.aspx" target="_blank"&gt;in MSDN&lt;/a&gt;. You can download source code from the link given at the end of the post.&lt;/p&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;h4&gt;Prepare the service to call from jQuery&lt;/h4&gt;  &lt;p&gt;Consider developing a service as described in my &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-create-custom-wcf.html" target="_blank"&gt;earlier post&lt;/a&gt; with the following changes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;For&amp;#160; using json I’ve used REST service factory ‘Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory’ as shown below. You can use SOAP factory but you then need to parse data in different way.      &lt;br /&gt;      &lt;div id="codeSnippetWrapper"&gt;       &lt;div id="codeSnippetWrapper"&gt;         &lt;div id="codeSnippetWrapper"&gt;           &lt;div id="codeSnippetWrapper"&gt;             &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&amp;lt;%@ ServiceHost Language=&lt;span style="color: #006080"&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; Debug=&lt;span style="color: #006080"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;br /&gt;    Service=&lt;span style="color: #006080"&gt;&amp;quot;AccessSPServiceFromJQuery.MyService, $SharePoint.Project.AssemblyFullName$&amp;quot;&lt;/span&gt;  &lt;br /&gt;    CodeBehind=&lt;span style="color: #006080"&gt;&amp;quot;MyService.svc.cs&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;    Factory=&lt;/strong&gt;&lt;span style="color: #006080"&gt;&lt;strong&gt;&amp;quot;Microsoft.SharePoint.Client.Services.&lt;font style="background-color: #ffff00"&gt;MultipleBaseAddressWebServiceHostFactory&lt;/font&gt;, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, &lt;br /&gt;&lt;/strong&gt;    Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

            &lt;br /&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div&gt;
      &lt;div&gt;
        &lt;div&gt;
          &lt;div&gt;Next you need to specify the return type to json in the service interface as shown below. I’ve specified both request and response type to json in WebInvoke attribute: 
            &lt;br /&gt;

            &lt;br /&gt;

            &lt;div id="codeSnippetWrapper"&gt;
              &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[ServiceContract]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IMyService&lt;br /&gt;{&lt;br /&gt;    [OperationContract]&lt;br /&gt;    [WebInvoke(Method = &lt;span style="color: #006080"&gt;&amp;quot;GET&amp;quot;&lt;/span&gt;, BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]&lt;br /&gt;    List&amp;lt;Product&amp;gt; SearchProduct(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; productName);&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    [OperationContract]&lt;br /&gt;&lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;    [WebInvoke(Method = &lt;span style="color: #006080"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;, BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Save(Product product);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

              &lt;br /&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;



&lt;div&gt;
  &lt;div&gt;
    &lt;div&gt;
      &lt;div&gt;&lt;font color="#ff0000"&gt;One thing to notice here is that you can’t access the service in browser with mex endpoint&lt;/font&gt;. For example if you service is &lt;a href="http://myserver/myservice.svc"&gt;http://myserver/myservice.svc&lt;/a&gt;, then the url &lt;a href="http://myserver/myservice.svc/mex"&gt;http://myserver/myservice.svc/mex&lt;/a&gt; will not work for service created with MultipleBaseAddressWebServiceHostFactory.&lt;/div&gt;

      &lt;div&gt;&amp;#160;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;h4&gt;Call Service with jQuery&lt;/h4&gt;

&lt;p&gt;The next step is to call the service with jQuery. The url of the service to be used in jQuery will be service url and method name. For example if you service url is &lt;strong&gt;‘/_vti_bin/AccessSPServiceFromJQuery/MyService.svc&lt;/strong&gt;’ and the method name you want to invoke is ‘Search’ then the full url will be ‘&lt;strong&gt;/_vti_bin/AccessSPServiceFromJQuery/MyService.svc/Search&lt;/strong&gt;’. As shown in the code below, you can invoke the service Search by passing the parameter in data field of ajax call of jquery&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; getProductFromService(searchText) {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; {&lt;br /&gt;        $.ajax({&lt;br /&gt;            type: &lt;span style="color: #006080"&gt;&amp;quot;GET&amp;quot;&lt;/span&gt;,&lt;br /&gt;            url: &lt;span style="color: #006080"&gt;'/_vti_bin/AccessSPServiceFromJQuery/MyService.svc/SearchProduct'&lt;/span&gt;,&lt;br /&gt;            contentType: &lt;span style="color: #006080"&gt;&amp;quot;application/json; charset=utf-8&amp;quot;&lt;/span&gt;,&lt;br /&gt;            data: { &lt;span style="color: #006080"&gt;&amp;quot;productName&amp;quot;&lt;/span&gt;: searchText },&lt;br /&gt;            dataType: &lt;span style="color: #006080"&gt;'json'&lt;/span&gt;,&lt;br /&gt;            success: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; (msg) {&lt;br /&gt;                WCFServiceGetSucceeded(msg);&lt;br /&gt;            },&lt;br /&gt;            error: WCFServiceGetFailed&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (e) {&lt;br /&gt;&lt;br /&gt;        alert(&lt;span style="color: #006080"&gt;'error invoking service.get()'&lt;/span&gt; + e);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; WCFServiceGetSucceeded(result) {&lt;br /&gt;    alert(&lt;span style="color: #006080"&gt;'success'&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; WCFServiceGetFailed(error) {&lt;br /&gt;    alert(&lt;span style="color: #006080"&gt;'Service Failed.'&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h4&gt;Download and use code&lt;/h4&gt;

&lt;p&gt;I’ve uploaded the code for this post in my skydrive. You can download the code from the link below. To use the code please ensure you have internet connection as I’ve used jqery from Microsoft CDN. The search functionality get all products matching name. You can try to search just by typing a single character. You can debug and test the code. In save I’ve just shown you can pass value from browser to service using POST method.&lt;/p&gt;
&lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="https://skydrive.live.com/embedicon.aspx/Public/SharePoint/AccessSPServiceFromJQuery.zip?cid=04d8f6d0dd4e7214&amp;amp;sc=documents" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-4490134441062525723?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/4490134441062525723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/09/sharepoint-2010-access-wcf-service-with.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4490134441062525723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4490134441062525723'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/09/sharepoint-2010-access-wcf-service-with.html' title='SharePoint 2010: Access WCF Service with jQuery'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-7179970340658069058</id><published>2011-08-24T10:36:00.000+02:00</published><updated>2011-08-24T10:37:20.939+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Ribbon UI'/><title type='text'>SharePoint 2010: Postback to the same page from Ribbon</title><content type='html'>&lt;p&gt;Most of the examples related to ribbon button actions involve opening dialog. However, if you need to send post back request to the same page/dialog where the ribbon exists, you need to trick a bit. Let’s explain how you can do so.&lt;/p&gt;  &lt;h4&gt;Define Ribbon XML&lt;/h4&gt;  &lt;p&gt;You can define the postback action in the command action in Ribbon xml file. To do so, you can use javascript function _doPostBack(‘token’,’’). This will send a postback request to the same page.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIHandler&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;Command&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;MyButton.Command&amp;quot;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;CommandAction&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;javascript:__doPostBack('MyButtonPostback','');&amp;quot;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #ff0000"&gt;EnabledScript&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Figure 1: PostBack action defined in Ribbon xml&lt;/strong&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Identify the PostBack request in the page&lt;/h4&gt;

&lt;p&gt;The second step is to identity from code behind file, if the postback occurred from ribbon button’s action. From the page load, you can check if the postback occurred due to the command “MyButton.Command”. To do so we can have a check shown below in the page load method.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Page.Request[&lt;span style="color: #006080"&gt;&amp;quot;__EVENTTARGET&amp;quot;&lt;/span&gt;] == &lt;span style="color: #006080"&gt;&amp;quot;MyButtonPostback&amp;quot;&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;//The ribbon button initiated the postback&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Though this is very simple trick but might be helpful for someone.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-7179970340658069058?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/7179970340658069058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/08/sharepoint-2010-postback-to-same-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7179970340658069058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7179970340658069058'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/08/sharepoint-2010-postback-to-same-page.html' title='SharePoint 2010: Postback to the same page from Ribbon'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5357981703175625150</id><published>2011-08-23T09:03:00.000+02:00</published><updated>2011-08-23T09:04:56.440+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Ribbon UI'/><title type='text'>SharePoint 2010: Modifying and Deploying Ribbon doesn’t update the ribbon</title><content type='html'>&lt;p&gt;Recently I’ve been working extensively with Ribbon. So what I did, I developed a ribbon and attached the ribbon to a feature. Then after modifying the ribbon in Visual Studio I deployed the ribbon again to see the changes. But interestingly the modification was not working. The ribbon was deployed successfully for the first time. But later I updated the ribbon xml in Visual studio and redeployed and the update to the ribbon was not showing in the site though the deployment was successful. Event I tried to deactivate/activate the ribbon feature but no luck. So the problem was ribbon update was not showing in effect in the site event after successful deployment.&lt;/p&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Solution&lt;/h4&gt;  &lt;p&gt;Finally I found the solution from Sandrino Di Mattia’s post &lt;a href="http://sandrinodimattia.net/blog/post/SharePoint-2010-Ribbon-customizations-not-working-as-expected.aspx" target="_blank"&gt;here&lt;/a&gt;. Basically, You need to modify the feature version every time you modify the ribbon and redeploy. First find which feature the ribbon is associated with. Then open the feature properties window and modify the feature version as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-lvNi1KWflo0/TlNQ6-JFPtI/AAAAAAAAAxg/8QVw0M1e9go/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-OUu9UC8Pxz8/TlNQ8GIjzjI/AAAAAAAAAxk/JlBA4X1UzYw/image_thumb%25255B1%25255D.png?imgmax=800" width="401" height="539" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Change Feature Version&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Another solution might be to clear your browser cache.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;So changing the feature version or clearing the browser cache or private browsing might be solution for getting ribbon update in browser.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5357981703175625150?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5357981703175625150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/08/sharepoint-2010-redeploying-ribbon.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5357981703175625150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5357981703175625150'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/08/sharepoint-2010-redeploying-ribbon.html' title='SharePoint 2010: Modifying and Deploying Ribbon doesn’t update the ribbon'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-OUu9UC8Pxz8/TlNQ8GIjzjI/AAAAAAAAAxk/JlBA4X1UzYw/s72-c/image_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-2202676911041465794</id><published>2011-06-26T12:48:00.000+02:00</published><updated>2011-07-24T10:05:18.828+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Ribbon UI'/><title type='text'>SharePoint 2010: Approve/Reject dialog customization, show changed values</title><content type='html'>&lt;p&gt;SharePoint provide rich support for approval process. You can maintain version of changes, you can use built-in workflows or develop your own for approval process. You can even create custom workflow activities and use it in SharePoint Designer to create your own approval workflow. Unfortunately, SharePoint doesn’t provide a nice UI where approver can get a snapshot of what’s changes he’s going to approve/reject. What we are familiar with the following UI:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-1BnDKrnF0fg/TgcPaF7cyhI/AAAAAAAAAvs/XPG6nGxkJ1o/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-lubBLf0G7xY/TgcPbf_GcNI/AAAAAAAAAvw/kG3De9Sj50A/image_thumb%25255B1%25255D.png?imgmax=800" width="511" height="412" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Very generic UI to approve/reject&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;What if we could have a dialog as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-BzBqRDpQC8k/TgcPcX2Q5jI/AAAAAAAAAv0/BLRtOCsggvw/s1600-h/image%25255B7%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-8m-JMkifbOw/TgcPdCTocgI/AAAAAAAAAv4/tzVrF7IfAM4/image_thumb%25255B3%25255D.png?imgmax=800" width="509" height="441" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Custom Approve/Reject dialog with modification highlighted&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As shown in figure 2, the approver will have the better look of what’s the changes he’ll approve/reject. As shown in figure 2, the person who will approve/reject, can get a snapshot of what changes are waiting for his/her approval.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;What’s the cost of custom approve/reject dialog?&lt;/h4&gt;  &lt;p&gt;Now the question comes what’s the development cost of such a custom approve/reject dialog? I’ve just developed few classes for returning a list of items with three fields (Field Name, Old Value and new Value) which can be bound to a grid. I’ve already provide the source code in here. But the development process is described below:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Create a custom action menu: &lt;/strong&gt;You can hide the custom approve/reject menu or you can keep it in place. What I’ve done is included a new custom action menu ‘Approve/Reject Single’ as shown in the image below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-5r1XTyOjsss/TgcPeMnMYUI/AAAAAAAAAv8/i8AP4faPUOs/s1600-h/image%25255B15%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-MsvyK1CjTKU/TgcPfK_zLBI/AAAAAAAAAwA/92lPp_4HAQM/image_thumb%25255B7%25255D.png?imgmax=800" width="630" height="310" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Custom action menu (Approve/Reject Single)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Create custom Application Page:&lt;/strong&gt; Next you need to develop a custom application page which will be shown in the dialog when the custom action menu (show in figure 3) will be clicked. The custom application page will show the changes (field name, old value and new value) as shown in figure 2.&lt;/p&gt;  &lt;h4&gt;Download and test the code&lt;/h4&gt;  &lt;p&gt;If you have downloaded my last code from blog “&lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/05/sharepoint-2010-approvereject-multiple.html" target="_blank"&gt;Approve/Reject Multiple Items&lt;/a&gt;” please uninstall the solution first. Either you may find conflict as I’ve used the source code from that post and modified for this post. You can download the code for this post from my MSDN code gallery &lt;a title="http://archive.msdn.microsoft.com/SP2010ApproRejectExt" href="http://archive.msdn.microsoft.com/SP2010ApproRejectExt" target="_blank"&gt;http://archive.msdn.microsoft.com/SP2010ApproRejectExt&lt;/a&gt;. Then from download tab download the second file “SharePoint.ApproveRejectTestWithVisual”. &lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;The provided code is not something that you can just download and deploy in production. The code is just for can-do sample which shows such a nice view of changed items possible. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-2202676911041465794?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/2202676911041465794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-2010-approvereject-dialog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2202676911041465794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2202676911041465794'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-2010-approvereject-dialog.html' title='SharePoint 2010: Approve/Reject dialog customization, show changed values'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-lubBLf0G7xY/TgcPbf_GcNI/AAAAAAAAAvw/kG3De9Sj50A/s72-c/image_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-7955663765929374066</id><published>2011-06-15T11:13:00.000+02:00</published><updated>2011-06-15T11:17:25.343+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Customize SharePoint Add/Edit/Display Form</title><content type='html'>&lt;p&gt;When you create a SharePoint list the default SharePoint add/edit/display form get its looks by its own. For example the fields appears in the add/edit/display form based on the sequence you added the fields. Also by default all fields of the list are shown in the forms. Sometimes you may need to give a hand to customized that look and feel. I’ll try to give some light on how you can customize the default add/edit/view form of SharePoint list.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Enable Content type Management First&lt;/h4&gt;  &lt;p&gt;To customize the List forms you need to enable ‘content type management’. You can do so from List settings Page and then click ‘Advance Settings’. Then select yes for “Allow management of content types” as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-C6tGLq-7Hx4/Tfh4auopuNI/AAAAAAAAAus/WKuTStLXTAY/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-hDKxbaqAHBI/Tfh4b83kbII/AAAAAAAAAuw/1cu7CMVX3gA/image_thumb%25255B1%25255D.png?imgmax=800" width="403" height="330" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Enable content type management.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once you have enabled the content type for a list you will find a available content types associated with the lists under ‘content types’ section of list settings page as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-hkeGtXG67PE/Tfh4coQ5g3I/AAAAAAAAAu0/rexUjhY4Ono/s1600-h/image%25255B7%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-9_fCZwLn8g4/Tfh4dhU8pMI/AAAAAAAAAu4/Nj97_JhXKnk/image_thumb%25255B3%25255D.png?imgmax=800" width="686" height="528" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Content type management section in list settings page&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160; &lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;Hide fields from add/edit/display form&lt;/h4&gt;  &lt;p&gt;Sometimes you may want to hide some fields from add/edit/display form. Scenario might be you don’t want users to edit the field directly, rather the hidden field’s data will be populated differently (maybe from event receiver or timer job). To do so click on the Content Type (usually Item) and then you will be landed in a page as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-iBnQvslQKYE/Tfh4eYwQgBI/AAAAAAAAAu8/WptwsykyFZk/s1600-h/image%25255B15%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-Y252Yl-aA-E/Tfh4glMScqI/AAAAAAAAAvA/L5DtWrPbD7o/image_thumb%25255B7%25255D.png?imgmax=800" width="607" height="560" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Item Content Type editing page&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As you see from figure 3, the content type page is showing all my field but only Product Name (internally the field name is Title) is coming from Item content type. Other fields are added by myself. Now let’s say you want to hide the launchDate field from add/edit/view form. To do so click the field link ‘Launch Date’ and you will be taken to a page as shown below. From that page you can hide a field. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-MdnNpxS2Wsc/Tfh4hQDsWTI/AAAAAAAAAvE/0pff8v_zlbE/s1600-h/image%25255B19%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-sm8m4Dnc_S8/Tfh4iHGmFtI/AAAAAAAAAvI/ka2lRWnXLng/image_thumb%25255B9%25255D.png?imgmax=800" width="562" height="354" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Hide fields if needed&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;          &lt;p&gt;For your information, the hidden field will not appear in add/edit/display from but you can still access the field in list views.&lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;h4&gt;Reorder Fields in add/edit/display form&lt;/h4&gt;  &lt;p&gt;You can reorder how the fields will appear in the list add/edit/display from. To do so take a look a the figure 3. You will find a link “Column Reorder” at the bottom of the item. Click the link and you will be moved to a page as shown below where you can reorder the presence of the fields in add/edit/display form.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-dXrzot5JYes/Tfh4iyfIfSI/AAAAAAAAAvM/_-JdRlzA3lM/s1600-h/image%25255B23%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-pqqW52HD47U/Tfh4jYSmiuI/AAAAAAAAAvQ/UxLnnCQuBRk/image_thumb%25255B11%25255D.png?imgmax=800" width="434" height="407" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 5: Reorder fields in add/edit/view forms&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;Want more customization?&lt;/h4&gt;  &lt;p&gt;If you are not even happy you can create your own custom add/edit/display from as &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-custom-addeditdisplay-form.html" target="_blank"&gt;described my another post&lt;/a&gt;. Also you can even edit the add/edit/display from in infopath. To do so open the site in IE browser and the navigate to list settings page. And then click “Form Settings” as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-YxJMsxPNuQ0/Tfh4kM6KVaI/AAAAAAAAAvU/si6X-DGswbE/s1600-h/image%25255B27%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-Mj04lJ_tKGE/Tfh4lGazldI/AAAAAAAAAvY/PVbBHiW8lYI/image_thumb%25255B13%25255D.png?imgmax=800" width="678" height="384" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 6: From settings option in list settings page.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Clicking on the form settings page, you will be navigated to a page as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-BgGDg9Uc9CU/Tfh4lpp1joI/AAAAAAAAAvc/woJhQ-F6Org/s1600-h/image%25255B31%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-pFDUP8WFpI8/Tfh4mzdY6jI/AAAAAAAAAvg/t017jHHzzWA/image_thumb%25255B15%25255D.png?imgmax=800" width="466" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 7: Form settings page.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;Clicking ok in the page as shown in figure 7, you will be asked to open the page in InfoPath editor as shown below. However you need to use IE browser to open the InfoPath editor directly from browser:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-QwDHTsnbefU/Tfh4n06Ia2I/AAAAAAAAAvk/lSdTxRyb8TY/s1600-h/image%25255B36%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-4vbWkGzsO-o/Tfh4onqXcNI/AAAAAAAAAvo/btL0wqoOUXU/image_thumb%25255B18%25255D.png?imgmax=800" width="708" height="383" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 8: Edit form in InfoPath.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I’m not going to bring InfoPath in today’s discussion as this can be more complex. However If I get chance I’ll come back to you with a post on “how to use InfoPath to edit the form”.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-7955663765929374066?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/7955663765929374066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-2010-customize-sharepoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7955663765929374066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7955663765929374066'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-2010-customize-sharepoint.html' title='SharePoint 2010: Customize SharePoint Add/Edit/Display Form'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-hDKxbaqAHBI/Tfh4b83kbII/AAAAAAAAAuw/1cu7CMVX3gA/s72-c/image_thumb%25255B1%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-1847303129258488232</id><published>2011-06-14T11:12:00.000+02:00</published><updated>2011-06-14T11:17:30.471+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint: Custom add/edit/display form for list</title><content type='html'>&lt;p&gt;Sometimes we don’t want to use SharePoint’s custom add/edit/display form. We want our own custom form when user will try to view, edit or add an item. I’ll show you today how easily we can do so.&lt;/p&gt;  &lt;p&gt;For this post I’ll consider I’ll have a list with three fields: Product Code, ProductName and ProductDescription. I’ll show how we can create a list with these two fields with custom add/edit/display form. The list’s fields are described in the table below:&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" width="707"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&lt;strong&gt;Field name&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="133"&gt;&lt;strong&gt;Field Type&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="439"&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Product Code&lt;/td&gt;        &lt;td valign="top" width="133"&gt;Text&lt;/td&gt;        &lt;td valign="top" width="439"&gt;Title field will be used instead of creating a new one&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Produce Name&lt;/td&gt;        &lt;td valign="top" width="133"&gt;Text&lt;/td&gt;        &lt;td valign="top" width="439"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Product Description&lt;/td&gt;        &lt;td valign="top" width="133"&gt;Text&lt;/td&gt;        &lt;td valign="top" width="439"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;Table 1: Custom list template/Content Type’s fields&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The first step of this approach is to create a content type with required fields associated with the content type. The noticeable point here is that In the content type declaration, we can define custom forms for add/edit/display.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 1: Create a content type for your list&lt;/h4&gt;  &lt;p&gt;To create content type right click on your project and click ‘add new item’ and then select content type as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-fC3OdorNgX8/TfcmZc7Q4gI/AAAAAAAAAt0/2lFUpR0llvo/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-lLyU3uiBnMM/Tfcmabtx2jI/AAAAAAAAAt4/owwjwPMc2kY/image_thumb1.png?imgmax=800" width="808" height="499" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Add content type&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Next you will be prompted for the base content type as shown below: If you want to create a custom list, you can select Item as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-KfslTkBZS90/Tfcma-RyeFI/AAAAAAAAAt8/0p_H4t3m96Q/s1600-h/image7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-uas2i9q7Iao/Tfcmbnr0vaI/AAAAAAAAAuA/Wzwlamwrsvk/image_thumb3.png?imgmax=800" width="608" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: ‘Item’ is the base content type for custom/generic list&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Then you will have provided the content xml file. You need to modify the content type xml file as shown below. Please modify the &lt;font style="background-color: #ffff00"&gt;Inherits=”False”&lt;/font&gt; from the content types.&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippetWrapper"&gt;     &lt;div id="codeSnippetWrapper"&gt;       &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #008000"&gt;&amp;lt;!--Defined fields--&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{30C3D21A-A7C9-410E-A896-82875475F697}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProductName&amp;quot;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Name&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Required&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;FALSE&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{9621763e-3494-4a86-a3eb-fd2593f1a1f1}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProductDescription&amp;quot;&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Description&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #008000"&gt;&amp;lt;!-- Parent ContentType: Item (0x01) --&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ContentType&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0x0100c5e54b7f62ad451a92f9235d43ec9082&amp;quot;&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProductContentType&amp;quot;&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: #ff0000"&gt;Group&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Custom Content Types&amp;quot;&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: #ff0000"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;My Content Type&amp;quot;&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: #ff0000"&gt;Inherits&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;false&amp;quot;&lt;/span&gt;&lt;br /&gt;               &lt;span style="color: #ff0000"&gt;Version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRefs&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRef&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{fa564e0f-0c70-4ab9-b863-0177e6ddd247}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Title&amp;quot;&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Code&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Sealed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRef&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{82642ec8-ef9b-478f-acf9-31f7d45fbc31}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LinkTitle&amp;quot;&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Code&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Sealed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRef&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{BC91A437-52E7-49E1-8C4E-4698904B2B6D}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LinkTitleNoMenu&amp;quot;&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Code&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Sealed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRef&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{30C3D21A-A7C9-410E-A896-82875475F697}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProductName&amp;quot;&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Name&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Required&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;False&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRef&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{9621763e-3494-4a86-a3eb-fd2593f1a1f1}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ProductDescription&amp;quot;&lt;/span&gt; &lt;br /&gt;                &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Description&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Required&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;False&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;FieldRefs&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocuments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocument&lt;/span&gt; &lt;span style="color: #ff0000"&gt;NamespaceURI&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FormUrls&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Display&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=display&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Display&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Edit&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=edit&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Edit&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;New&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=new&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;New&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;FormUrls&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocuments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ContentType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;strong&gt;Figure 3: Content Type xml file with fields and add/edit/display form declared&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now let’s explain what’s in the xml shown in figure 3. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Firstly I’ve modified Inherits to false in ConentType tag.&lt;/li&gt;

  &lt;li&gt;I’ve defined two fields inside the &amp;lt;Elements&amp;gt; tag that I’ve used later in content types&lt;/li&gt;

  &lt;li&gt;Then used those fields in &amp;lt;FieldRefs&amp;gt; of &amp;lt;ContentType&amp;gt; tags. These fields will be available in Content type. I’ve also used three existing fields (for Title) from base Content Type (Item). &lt;/li&gt;

  &lt;li&gt;Finally I’ve defined New, Edit and Display form for these content types in &amp;lt;XmlDocuments&amp;gt; section. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Step 2: Create a list Template based on Content type&lt;/h4&gt;

&lt;p&gt;Now you have defined content types with three fields. Next step is to define a list template based on the content type. To do so click add new item from visual studio context menu and select “List Definition From Content Type” as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/-NBU82uIqvX0/TfcmcDzlwpI/AAAAAAAAAuE/wM4bSsZLwl8/s1600-h/image5.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-n2nuH3AXbGU/TfcmctAYw_I/AAAAAAAAAuI/Np5cCDILvyw/image_thumb2.png?imgmax=800" width="714" height="445" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 4: Create list definition from content type in ‘Create new Item’ dialog.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next you will be prompted for available&amp;#160; content types in the project as shown below. Remember to uncheck the button ‘Add a list instance for this list definition’ for this demo now.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-u6MqIkFXKFE/TfcmdJtyi4I/AAAAAAAAAuM/tUIVhTl1Aq8/s1600-h/image9.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/---0uL1iGUCA/Tfcmd2EI-OI/AAAAAAAAAuQ/daSCwZkEpUo/image_thumb4.png?imgmax=800" width="608" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 5: Create list definition from Content Type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now you will find two files Elements.xml and Schema.xml files are added. Our full focus will be now on Schema.xml. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Modify the content in &amp;lt;Fields&amp;gt; tag:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ensure Title fields with display name ‘product code’ exists as shown below:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Field&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{fa564e0f-0c70-4ab9-b863-0177e6ddd247}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Title&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Product Code&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Sealed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Text&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-7Fl3X5JGy0Q/TfcmecT5pZI/AAAAAAAAAuU/vRlKrCabUOM/s1600-h/image18.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-wqD26r98jRY/TfcmfU8jqFI/AAAAAAAAAuY/sq43YkvqiRo/image_thumb9.png?imgmax=800" width="743" height="301" /&gt;&lt;/a&gt;

  &lt;br /&gt;&lt;strong&gt;Figure 6: Add title field in the list template (if not exists)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then find two fields LinkTitle and LinkTitleNoMenu. Then change their display name to ‘Product Code’ as shown below. These two fields are link to edit menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/-Mnm_obqY32k/TfcmgD6RtWI/AAAAAAAAAuc/h7naTtQFjxc/s1600-h/image23.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-X2PlfNkIdYg/TfcmhA8AixI/AAAAAAAAAug/WJOXnfvyWJI/image_thumb12.png?imgmax=800" width="817" height="482" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 7: Rename the displayName for linkTitle and LinkTitleNoMenu field&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Modify the content in &amp;lt;Views&amp;gt; tag&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open the views tag and add the fields you want to display in default view under &amp;lt;View&amp;gt; with Default value is true as shown below. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-8GzoqlBgin4/Tfcmh1Zk9LI/AAAAAAAAAuk/lqVMwC-UrhM/s1600-h/image27.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-WifYMNqrCto/Tfcmi-BBcsI/AAAAAAAAAuo/V1kS1RHGZJY/image_thumb14.png?imgmax=800" width="583" height="563" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 8: Define the fields to be shown in default view&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;&amp;#160;&lt;/h4&gt;

&lt;h4&gt;&amp;#160;&lt;/h4&gt;

&lt;h4&gt;Step 3: Create Custom add/edit/display form&lt;/h4&gt;

&lt;p&gt;Next step is to develop a custom application page to use for add/edit/display. As sown in figure 3, you can three different pages for add, edit and view. However for brevity I want to use a single page for all these three operations. You need to create an application page in appropriate location (in my case this is _layouts/blogtest folder). Rather than using three different files for add/edit/display, you can use a single page for all these three tasks as shown below:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocuments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocument&lt;/span&gt; &lt;span style="color: #ff0000"&gt;NamespaceURI&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;FormUrls&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Display&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=display&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Display&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Edit&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=edit&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Edit&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;New&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;_layouts/blogtest/Product.aspx?mode=new&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;New&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;FormUrls&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocument&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;XmlDocuments&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;By passing different parameter to a single page we can identity the page’s mode (add, edit or view). Also SharePoint by default add the list and item id at the end of the page. So your page’s url will look like for new item:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;_layouts/blogtest/Product.aspx?mode=&lt;font style="background-color: #ffff00"&gt;new&lt;/font&gt;&amp;amp;List=&lt;font style="background-color: #ffff00"&gt;LISTGUID&lt;/font&gt;&amp;amp;ID=&lt;font style="background-color: #ffff00"&gt;ITEMID&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So from the page (Product.aspx) you can identity the list id and item id from querystring.&lt;/p&gt;

&lt;p&gt;I’m not showing details of the product.aspx page here. &lt;/p&gt;

&lt;p&gt;You can download the full source code from &lt;a href="http://cid-04d8f6d0dd4e7214.office.live.com/self.aspx/Public/SharePoint/CustomFormsForList.zip" target="_blank"&gt;this skydrive link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;How to use the project attached with this post?&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Download the &lt;a href="http://cid-04d8f6d0dd4e7214.office.live.com/self.aspx/Public/SharePoint/CustomFormsForList.zip" target="_blank"&gt;code from here&lt;/a&gt;.&lt;/li&gt;

  &lt;li&gt;Deploy the solution to a SharePoint site.&lt;/li&gt;

  &lt;li&gt;Create a new list with “ProductListDefinition” template. This template will be installed in the site as you deploy the SharePoint solution.&lt;/li&gt;

  &lt;li&gt;Now try to add/edit/view items in the list. You will find the custom form product.aspx is used for add/edit/view.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;



&lt;p&gt;Hope some persons might find the post useful..&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-1847303129258488232?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/1847303129258488232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-custom-addeditdisplay-form.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1847303129258488232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1847303129258488232'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-custom-addeditdisplay-form.html' title='SharePoint: Custom add/edit/display form for list'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-lLyU3uiBnMM/Tfcmabtx2jI/AAAAAAAAAt4/owwjwPMc2kY/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-1972239474728983707</id><published>2011-06-07T10:36:00.000+02:00</published><updated>2011-06-07T10:42:39.400+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint: Disable Event Receiver From non-receiver code</title><content type='html'>&lt;p&gt;When we are in List Item Event Receiver code, we can modify/update the same item which will fire the event receiver again. For disabling event receiver to get fired again we can use the property ‘’ as shown below:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; TestEventReceiver:SPItemEventReceiver&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ItemAdded(SPItemEventProperties properties)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #008000"&gt;//disable event receiver firing&lt;/span&gt;&lt;br /&gt;        EventFiringEnabled = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: #008000"&gt;//do something&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;        &lt;span style="color: #008000"&gt;//enalbe event receiver firing&lt;/span&gt;&lt;br /&gt;        EventFiringEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Figure 1: Sample code to enable/disable event receiver firing inside event receiver handler.&lt;/strong&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;However, if you are in a webpart and want to modify an item but don’t want to fire event receiver, then? Don’t worry there’s a way out. I’ll explain this today.&lt;/p&gt;

&lt;h4&gt;&amp;#160;&lt;/h4&gt;

&lt;h4&gt;What happens when Event Receiver disabled?&lt;/h4&gt;

&lt;p&gt;When you disable event receiver, SharePoint internally set a data field in current Thread. So if you can set your current’s thread’s data to the required value before/after updating item, you can control the event receiver. However, setting current thread data manually might be risky and I’ll not use that path. Rather I’ll show how we can use existing power of ‘SPEventReceiverBase’ to control event receiver firing.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Create your own Event Receiver Controller&lt;/h4&gt;

&lt;p&gt;I’ve create a custom class inherited from ‘&lt;strong&gt;SPEventReceiverBase’&lt;/strong&gt;. From this base class I get a properties ‘&lt;strong&gt;EventFiringEnabled’&lt;/strong&gt; which allows me to control the event receiver firing. The following code snippet shows my custom EventReceiverManager:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; EventReceiverManager : SPEventReceiverBase, IDisposable&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; EventReceiverManager(&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; disableImmediately)&lt;br /&gt;    {&lt;br /&gt;        EventFiringEnabled = !disableImmediately;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; StopEventReceiver()&lt;br /&gt;    {&lt;br /&gt;        EventFiringEnabled = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; StartEventReceiver()&lt;br /&gt;    {&lt;br /&gt;        EventFiringEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Dispose()&lt;br /&gt;    {&lt;br /&gt;        EventFiringEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Figure 2: A EventReceiverManager custom class to control event receiver firing.&lt;/strong&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The code snippet above is derived from SharePoint’s &lt;strong&gt;SPEventReceiverBase&lt;/strong&gt; to use the ‘&lt;strong&gt;EventFireingEnabled’&lt;/strong&gt; property.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now you can use this EventReceiverManager to control the event receiver. To stop firing the event receiver on any changes, you need to wrap the code block inside EventReceiverManager as shown below:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (var eventReceiverManager = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventReceiverManager(&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;))&lt;br /&gt;{&lt;br /&gt;    var list = GetList(&lt;span style="color: #006080"&gt;&amp;quot;listName&amp;quot;&lt;/span&gt;);&lt;br /&gt;    var listItem = list.GetItemById(itemId);&lt;br /&gt;    listItem[&lt;span style="color: #006080"&gt;&amp;quot;field&amp;quot;&lt;/span&gt;] = &lt;span style="color: #006080"&gt;&amp;quot;value&amp;quot;&lt;/span&gt;;&lt;br /&gt;    listItem.Update();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Figure 3: How to use EventReceiverManager to disable event receiver firing.&lt;/strong&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;p&gt;As shown above even if he list has event receiver for ItemUpdated/ItemDating the event receiver will not get fired because of putting the code in EventReceiverManager block. Please notice of ‘using’ block, as soon as you leave the ‘using’ block, the event firing in enabled automatically. This is because in Dispose method of EventReceiverManager I’ve enabled the event firing. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-1972239474728983707?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/1972239474728983707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-disable-event-receiver-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1972239474728983707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1972239474728983707'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/06/sharepoint-disable-event-receiver-from.html' title='SharePoint: Disable Event Receiver From non-receiver code'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-9049639983607586815</id><published>2011-05-22T11:07:00.000+02:00</published><updated>2011-07-25T10:26:53.215+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Approve/Reject Multiple Items</title><content type='html'>&lt;p&gt;You can approve/Reject an item from SharePoint ribbon. But only one item can be approved or rejected. But I’ve found requirements from few of my clients that they want to approve/reject in batch rather than one by one. This is logical. If there’s 100 of items to approve/reject, doing this one by one is tedious. In this post I’ve described&amp;#160; how I’ve implemented the idea and at the end of the blog you can find the link to download the source code.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;My approach to allow multiple approve/reject in batch is following the steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Add a new ribbon “Approve/Reject Selection” as shown below. The new ribbon will be active when more than one item will be selected.      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TdjSiV2O63I/AAAAAAAAAtU/YH2YdeQsA3I/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TdjSjVXnVVI/AAAAAAAAAtY/CdGK9R5oQJk/image_thumb1.png?imgmax=800" width="418" height="110" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 1: New ribbon “Approve/Reject Selection” added        &lt;br /&gt;&lt;/strong&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;When multiple item will be selected from grid the “Approve/Reject Selection” will be active as shown below:      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TdjSkNh9X8I/AAAAAAAAAtc/pvMwQJJbeUE/s1600-h/image7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TdjSlH9HrcI/AAAAAAAAAtg/nQc9gNHJ_hw/image_thumb3.png?imgmax=800" width="561" height="263" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 2: “Approve/Reject Selection” will be active when multiple items will be selected        &lt;br /&gt;&lt;/strong&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Clicking on “Approve/Reject Selection” will bring up a new custom window developed my me as shown below:      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TdjSlxeUkgI/AAAAAAAAAtk/I2tfPQxRJT0/s1600-h/image11.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TdjSmc4bwJI/AAAAAAAAAto/uTfapLbr79A/image_thumb5.png?imgmax=800" width="430" height="286" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 3: Approve/Reject Multiple items dialog        &lt;br /&gt;&lt;/strong&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Finally, the custom dialog shown in figure 3, is an application page where we need to write code to approve/reject selected items programmatically.      &lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So let’s start with the process of implementing the idea!!!!!!!!!!!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 1: Create a custom ribbon&lt;/h4&gt;  &lt;p&gt;First add a new empty element as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TdjSnHrwrhI/AAAAAAAAAts/SifPvvtKVtk/s1600-h/image15.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TdjSoDsjpXI/AAAAAAAAAtw/1S4Dhf2xqqs/image_thumb7.png?imgmax=800" width="702" height="552" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Add new empty element&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Then add the following xml in the elements.xml file:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CustomAction&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;Id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;COB.SharePoint.Ribbon.NewControlInExistingGroup&amp;quot;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;Location&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;CommandUI.Ribbon.ListView&amp;quot;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;RegistrationType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;List&amp;quot;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;RegistrationId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIExtension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIDefinition&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Location&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ribbon.ListItem.Workflow.Controls._children&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;COB.SharePoint.Ribbon.NewControlInExistingGroup.Notify&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Command&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;COB.Command.NewControlInExistingGroup.Notify&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Sequence&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;21&amp;quot;&lt;/span&gt; &lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Image16by16&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;/_layouts/$Resources:core,Language;/images/formatmap16x16.png&amp;quot;&lt;/span&gt; &lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Image16by16Top&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-48&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Image16by16Left&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-240&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Image32by32&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;/_layouts/$Resources:core,Language;/images/formatmap32x32.png&amp;quot;&lt;/span&gt; &lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Image32by32Top&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-448&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Image32by32Left&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-384&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Uses the notification area to display a message.&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;LabelText&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Approve/Reject Selection&amp;quot;&lt;/span&gt;&lt;br /&gt;                  &lt;span style="color: #ff0000"&gt;TemplateAlias&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;o1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIDefinition&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIHandlers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIHandler&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #ff0000"&gt;Command&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;COB.Command.NewControlInExistingGroup.Notify&amp;quot;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #ff0000"&gt;EnabledScript&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;javascript:enableApprovalAll();&amp;quot;&lt;/span&gt;&lt;br /&gt;          &lt;span style="color: #ff0000"&gt;CommandAction&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;javascript: showApproveAll(); &amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIHandlers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;CommandUIExtension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;CustomAction&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;CustomAction&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;Id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;COB.Command.NewControlInExistingGroup.Notify.Script&amp;quot;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;Location&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ScriptLink&amp;quot;&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #ff0000"&gt;ScriptSrc&lt;/span&gt; &lt;span style="color: #0000ff"&gt;=&amp;quot;/_layouts/SharePoint.ApproveRejectTest/Scripts/ApproveReject.js&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Elements&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Figure 5: Code snippet for Custom Ribbon&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m not going to describe the code snippet at figure 5 elaborately. However the basic things are that, I’m adding a button with label “Approve/Reject Selection” and I’ve associated two commands with the button. One is when to enable/disable the button with CommandUIHandler’s EnableScript attribute. The buttton click event action is defined with CommandAction attribute. If you notice I’ve just mentioned two javascript function &lt;strong&gt;enableApproveAll&lt;/strong&gt; and &lt;strong&gt;showApproveAll&lt;/strong&gt;. These two functions are not defined in this xml. Rather they are defined in another file &lt;strong&gt;“/_layouts/SharePoint.ApproveRejectTest/Scripts/ApproveReject.js&lt;/strong&gt;” which is referenced in xml file.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Step 2: Create the script file to show/hide approve/reject dialog&lt;/h4&gt;

&lt;p&gt;The content of the&amp;#160; ApproveReject.js file is show below. The command to show the approve/reject dialog is declared in this script. The function showApproveAll() will show a custom application page that I’ve described in step 3. The reference section in the file helps to get intellisense. I’ve not explained the script that much as it’s not in the scope of this post.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/MicrosoftAjax.js&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.debug.js&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.Core.debug.js&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.Ribbon.debug.js&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;_layouts/SP.UI.Dialog.debug.js&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/actionmenu.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/ajaxtoolkit.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/CUI.debug.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/portal.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.Exp.debug.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.Runtime.debug.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;reference path=&amp;quot;/_layouts/SP.UI.Dialog.debug.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//used to show approve/reject dialog&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; showApproveAll() {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; ctx = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SP.ClientContext.get_current();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; ItemIds = &lt;span style="color: #006080"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//get current list id&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; listId = SP.ListOperation.Selection.getSelectedList();&lt;br /&gt;    &lt;span style="color: #008000"&gt;//get all selected list items&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; selectedItems = SP.ListOperation.Selection.getSelectedItems(ctx);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//collect selected item ids&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; i = 0; i &amp;lt; selectedItems.length; i++) {&lt;br /&gt;        ItemIds += selectedItems[i].id + &lt;span style="color: #006080"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//prepare cutom approval page with listid &lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//and selected item ids passed in querystring&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; pageUrl = SP.Utilities.Utility.getLayoutsPageUrl(&lt;br /&gt;        &lt;span style="color: #006080"&gt;'/SharePoint.ApproveRejectTest/ApproveAll.aspx?ids='&lt;/span&gt; + ItemIds + &lt;span style="color: #006080"&gt;'&amp;amp;listid='&lt;/span&gt; + listId);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; options = SP.UI.$create_DialogOptions();&lt;br /&gt;    options.width = 420;&lt;br /&gt;    options.height = 250;&lt;br /&gt;    options.url = pageUrl;&lt;br /&gt;    options.dialogReturnValueCallback = Function.createDelegate(&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;, OnDialogClose);&lt;br /&gt;    SP.UI.ModalDialog.showModalDialog(options);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//used to determine whether the 'approve/reject selection' &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//ribbon will be enalbed or disabled&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; enableApprovalAll() {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; ctx = &lt;span style="color: #0000ff"&gt;new &lt;/span&gt;SP.ClientContext.get_current();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; SP.ListOperation.Selection.getSelectedItems(ctx).length &amp;gt; 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//called on dialog closed&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; OnDialogClose(result, target) {&lt;br /&gt;    &lt;span style="color: #008000"&gt;//if ok button is clicked in dialog, reload the grid.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (result == SP.UI.DialogResult.OK) {&lt;br /&gt;        location.reload(&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

    &lt;br /&gt;&lt;/div&gt;

  &lt;div&gt;&amp;#160;&lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;&lt;strong&gt;Figure 6: ApproveReject.js&amp;#160; file &lt;/strong&gt;&lt;/div&gt;

&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;In the method showApproveAll, I’ve collected the selected Items’ IDs and passed to “ApproveAll.aspx” page as querystring. I’ve also passed the current list id in querystring. 
  &lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;h4&gt;Step 3: Create custom Approve/Reject application page&lt;/h4&gt;

&lt;p&gt;Finally I’ve developed a application page named as “ApproveAll.aspx”. The partial markup of the page is shown below:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Content&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Main&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;PlaceHolderMain&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;script&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt;&amp;#160; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; closeDialog() {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;             SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, &lt;span style="color: #006080"&gt;'Cancelled clicked'&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; finisheDialog() {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;             SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, &lt;span style="color: #006080"&gt;'Cancelled clicked'&lt;/span&gt;);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;script&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;h2&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;divMessage&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;h2&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;table&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                Status:&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:DropDownList&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ddlAprovalOptions&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Approve&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Approved&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Pending&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Pending&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:ListItem&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Reject&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Denied&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:DropDownList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                Comments:&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:TextBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;txtComments&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;TextMode&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;MultiLine&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Columns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;40&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Rows&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;MaxLength&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;255&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;btnSubmit&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;OK&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;OnClick&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;btnOk_Click&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;input&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;button&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;btnCancel&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Cancel&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;closeDialog()&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;td&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;tr&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;table&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;asp:Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Figure 7: ApproveAll.aspx page’s markup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the code behind of the page, you need to extract the list id and list item ids. Then you need to invoke a method like shown below to approve/reject items:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ApproveRejectItems(SPWeb web, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; listId, SPModerationStatusType moderationStatusType, List&amp;lt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt; itemIDs)&lt;br /&gt;{&lt;br /&gt;    web.AllowUnsafeUpdates = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;    SPList spList = web.Lists[&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Guid(listId)];&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var itemId &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; itemIDs)&lt;br /&gt;    {&lt;br /&gt;        SPListItem spListItem = spList.GetItemById(itemId);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;//disable workflow&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (SPWorkflow workflow &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; spListItem.Workflows)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (workflow.ParentAssociation.Id == spList.DefaultContentApprovalWorkflowId)&lt;br /&gt;            {&lt;br /&gt;                SPWorkflowManager.CancelWorkflow(workflow);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;//update moderation status&lt;/span&gt;&lt;br /&gt;        spListItem.ModerationInformation.Comment = txtComments.Text;&lt;br /&gt;        spListItem.ModerationInformation.Status = moderationStatusType;&lt;br /&gt;        spListItem.Update();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Figure 8: Approve/Reject items&lt;/strong&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;As shown in the code snippet in figure 8, first we need to make sure we disable content approval workflow, if exists. Then we can update the moderation status.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Download Source Code&lt;/h4&gt;

&lt;p&gt;You can download the code for this post from my MSDN code gallery &lt;a href="http://archive.msdn.microsoft.com/SP2010ApproRejectExt" target="_blank"&gt;http://archive.msdn.microsoft.com/SP2010ApproRejectExt&lt;/a&gt;. Then from download tab download the first file “SharePoint.ApproveRejectTest”. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-9049639983607586815?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/9049639983607586815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/05/sharepoint-2010-approvereject-multiple.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/9049639983607586815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/9049639983607586815'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/05/sharepoint-2010-approvereject-multiple.html' title='SharePoint 2010: Approve/Reject Multiple Items'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TdjSjVXnVVI/AAAAAAAAAtY/CdGK9R5oQJk/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-9211293207257923415</id><published>2011-04-25T10:38:00.000+02:00</published><updated>2011-04-25T10:46:20.655+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint Development Environment: Virtual Machine Or Virtual Hard Disk (VHD) with Dual boot</title><content type='html'>&lt;p&gt;It’s true that SharePoint team has made the SharePoint rich enough to be useful in any organization. But they have taken less care of developers (my personal opinion). Developing with SharePoint was really a nightmare in old days (in SharePoint 2007) and the situation has not been changed that much today. I reminisce the days back in 2008 when four members of our SharePoint team worked in a single SharePoint server by logging in remotely. When one developer needed to reset IIS he needed to to inform others either he may interrupt some others’ debugging session.&lt;/p&gt;  &lt;p&gt;From that nightmare development experience of my first SharePoint project, I’ve come to a better place. Now I’ve Core I7, 8GB ram laptop. But I used to work in Virtual Machine till few months ago and I had got slower disk access in Virtual Machine. So compiling, debugging and deploying was relatively slow. I don’t want to install SharePoint in my laptops’ Windows 7 and I hope fewer (possibly fewest)&amp;#160; people want to do so. &lt;/p&gt;  &lt;p&gt;I’ve personally found developers who are coming to SharePoint Development from Asp.net, has got it difficult to get used to this environmental complexity. Anyway I’ve come to know about Virtual Hard Disk (VHD) solution few months ago and I’ve found it really a healthy approach. Let’s dig it deeper.&lt;/p&gt;  &lt;h4&gt;SharePoint Development in Virtual Machine &lt;/h4&gt;  &lt;p&gt;If you use Virtual Machine or any other virtual solution, you will have to realize that you will not the full processing power of your computer in SharePoint development. Even if in my Core I7 with 8GB ram, I get the development in Virtual Machine slower. If you do a lot of debugging and deployment you may loose your patience soon. However the real benefits include you can save virtual machine state. You can backup your virtual machine and restore.&lt;/p&gt;  &lt;h4&gt;SharePoint Development with Virtual Hard Disk (VHD)&lt;/h4&gt;  &lt;p&gt;Though I knew the concept of&amp;#160; Virtual Hard Disk about a year about ago, I didn’t get interested about it till few months ago. Basically the concept if you will have a Hard Disk (virtual obviously) and you will mount that virtual disk as a drive in your computer. Then you will install OS in that drive and add that OS in boot menu in your computer. So you will have more than one operating system in your computer but the OS will be in Virtual Hard Disk (which is a .vhd file). I’m going to describe it in details:&lt;/p&gt;  &lt;h4&gt;Create and Initialize a Virtual Hard Disk&lt;/h4&gt;  &lt;p&gt;&lt;font style="background-color: #ffff00"&gt;For your information, the following option for creating VHD file from “Computer Management” is only available in Windows Server 2008 R2 and Windows 7&lt;/font&gt;. I’ve not explored if the option shown below is available for other operating systems.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open the “Computer Management” from Administrator tools and right click on the “Disk Management” and click “Create VHD” as shown below:      &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzfoplVFI/AAAAAAAAAr0/TWkp7W6Gw30/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TbUzgzmKIBI/AAAAAAAAAr4/b8BbtFvdmqQ/image_thumb1.png?imgmax=800" width="318" height="474" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 1: Create VHD option in disk management       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Then in the New VHD window, enter appropriate value as shown below:     &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUzhpfEf1I/AAAAAAAAAr8/iROsav5cWQA/s1600-h/image7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUziXf_SjI/AAAAAAAAAsA/jwLOt3L0miQ/image_thumb3.png?imgmax=800" width="396" height="382" /&gt;&lt;/a&gt;      &lt;br /&gt;      &lt;br /&gt;&lt;strong&gt;Figure 2: Create new VHD settings page       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;After that you will find a new disk is added as shown below:     &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUzjpvEEkI/AAAAAAAAAsE/giyG1bFwLDM/s1600-h/image12%5B1%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUzlDT0SzI/AAAAAAAAAsI/nmnFBzx5bvA/image12_thumb.png?imgmax=800" width="654" height="390" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 3 New disk created for VHD       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;So you have found you new VHD as new disk but the disk need to initialized. To do right click on the new disk and click initialize as shown below:     &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TbUzlxCqAoI/AAAAAAAAAsM/jhC1FayYKtw/s1600-h/image20.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TbUzm3ReSFI/AAAAAAAAAsQ/is4FTrzxY9M/image_thumb10.png?imgmax=800" width="271" height="270" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 4: Initialize Virtual Hard Disk       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;However when you’ll try to initialize the disk you will prompted for partition style. Its recommended MBR as shown below:     &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUznjr6HxI/AAAAAAAAAsU/vZJ1q_K_y6g/s1600-h/image28.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzoxAkPFI/AAAAAAAAAsY/-CmqI_PcKLs/image_thumb14.png?imgmax=800" width="421" height="320" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 5: Create MBR partition in new VHD       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;After that you will find the disk (disk 1 in above figure) online. After that create a new volume in that virtual disk as shown below:     &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUzpmgWnTI/AAAAAAAAAsc/r0kvSxkfIYg/s1600-h/image32.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzqYSCbCI/AAAAAAAAAsg/2aJR0B5isUY/image_thumb16.png?imgmax=800" width="501" height="268" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 6: Create new sample volume in Virtual (but online) disk.       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;In the “New Sample Volume Wizard”, you can go with default settings and finally you will get a new drive in your computer which is virtual.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Mount a VHD and Install OS &lt;/h4&gt;  &lt;p&gt;Once you have your Virtual Hard Disk (VHD) ready you can try to install an OS in the VHD. To do so insert a Bootable CD/DVD in the CD/DVD-ROM and reboot your computer. To boot from CD/DVD make sure boot from CD/DVD enabled. I had tried to install Windows Server 2008 R2 in VHD. The process is described below:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;First, let the OS to start from bootable disk. Then when the following window comes up, press Shift + F10 to bring command prompt.     &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUzs1X7UeI/AAAAAAAAAsk/zMKyYqwCsfs/s1600-h/image%5B9%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzuacK5jI/AAAAAAAAAso/3PuXXr0QytY/image_thumb%5B3%5D.png?imgmax=800" width="591" height="447" /&gt;&lt;/a&gt;      &lt;br /&gt;      &lt;br /&gt;Figure 7: Windows Server 2008 R2 installation window.      &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;When the command prompt comes up (after press Shift + F10), type &lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;diskpart&lt;/font&gt;&lt;/strong&gt; and press enter. And then type &lt;font style="background-color: #ffff00"&gt;list volume&lt;/font&gt; and press enter to see all volumes available.      &lt;br /&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUzva5fc1I/AAAAAAAAAss/AjtIVPfFM-A/s1600-h/image%5B14%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TbUzwk5-bjI/AAAAAAAAAsw/4eOnjSoJIGU/image_thumb%5B6%5D.png?imgmax=800" width="615" height="466" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 8: Use diskpart command to list volumes.       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;You will find from “list volume” command that your drive letter is shifted by a letter (so, C becomes D, D becomes E and so on). Now type &lt;font style="background-color: #ffff00"&gt;Select vdisk file=”VhdFilePath”&lt;/font&gt; as shown in the image below:      &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUzxiXABJI/AAAAAAAAAs0/aKgFPlNpbLE/s1600-h/image%5B19%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzyjF9y5I/AAAAAAAAAs4/Ok999myuT4Q/image_thumb%5B9%5D.png?imgmax=800" width="589" height="495" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 9: Select VHD file command       &lt;br /&gt;        &lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Now you have selected the vhd file and you need to attach the file. To do so, run the command “&lt;font style="background-color: #ffff00"&gt;attach vdisk&lt;/font&gt;” as shown below      &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUzzuER4pI/AAAAAAAAAs8/IPodmgDlAWA/s1600-h/image%5B24%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUz039TyfI/AAAAAAAAAtA/k5LsnvJtWn4/image_thumb%5B12%5D.png?imgmax=800" width="607" height="512" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 10: Attach Vdisk command       &lt;br /&gt;&lt;/strong&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;You have selected vdisk and attached it. Now close the diskpart by typing Exit and then close the command prompt by typing exit again.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Now you can click Next in the “Install Windows” wizard as shown in figure 7. As you have attached the vdisk in the system, Installer will show the vhd as an disk and you can then choose to install OS in that vhd disk.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;When the Installation options come to choose the drive where to install OS, you can choose the VHD mounted disk (as shown in the image below). However you may get an warning saying “Windows Cannot be installed…” if you select the VHD for installing OS. Ignore the warning and install the OS in the vhd mounted disk.     &lt;br /&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUz2HkWWVI/AAAAAAAAAtE/qV26qeJLrbs/s1600-h/image%5B28%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TbUz3aDJJ7I/AAAAAAAAAtI/sATkVYy8q58/image_thumb%5B14%5D.png?imgmax=800" width="643" height="487" /&gt;&lt;/a&gt;      &lt;br /&gt;&lt;strong&gt;Figure 11: Select VHD disk to install OS&lt;/strong&gt;      &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;And when the installation will be finished, you will find your another OS is added in your boot menu.     &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So the final output is a file (VHD file) which is used for dual boot. You can copy the vhd file and attach it to another pc.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Attach an Existing VHD to boot option&lt;/h4&gt;  &lt;p&gt;Now say you have a vhd file and you need to attach the vhd file in boot option in your pc. You can do so with command. Fortunately, there’s GUI tools available to edit boot loader options. One such tool I’ve used is &lt;a href="http://neosmart.net/dl.php?id=1" target="_blank"&gt;EasyBCD&lt;/a&gt;. I’ve shown below how to add a VHD file in boot menu.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Run EasyBCD and click “Add New Entry”.&lt;/li&gt;    &lt;li&gt;From the bottom click “Virtual Disk” tab and then select the vhd file from disk.&lt;/li&gt;    &lt;li&gt;Finally click “Add Entry” to add the entry in boot option.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The following image shows process in a glance:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUz4rfNFsI/AAAAAAAAAtM/wgcr2kZdjxE/s1600-h/image%5B32%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TbUz5oN1b4I/AAAAAAAAAtQ/3xoZe8wJURY/image_thumb%5B16%5D.png?imgmax=800" width="685" height="521" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Figure 12: Add VHD file in boot option with EasyBCD&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now when you will restart your pc, you will find the new newly added entry is in boot option. &lt;font color="#ff0000"&gt;Be cautious while you edit your boot menu. Improper editing of boot menu may fail your booting system.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;If you are working with SharePoint frequently (as I do), you need to care about every minutes you are loosing for working in Virtual Environment. Since few months ago I had used Virtual Environment in my powerful laptop (Core-i7, 8GB RAM). However, disk access in VM environment is slow and as Visual Studio performance is somehow related to disk access (as during build a lot of disk read/write access operations are performed) so finally performance was a major problem.&lt;/p&gt;  &lt;p&gt;Now I’ve moved my work to VHD and I’ve two VHD files (one for SharePoint Foundation and another is for SharePoint Server). I’ve three OS in my boot options: Windows 7 (installed with my laptop), SharePoint Foundation and SharePoint Server. I can remove any boot option from my boot menu any time with EasyBCD. &lt;font color="#ff0000"&gt;And most of all, with VHD option, I get the full power of my laptop. If you guys have doubt about VHD option, I’ll ask you to give VHD option a try and I do believe you will like it. You will have to like it. &lt;/font&gt;&lt;font color="#000000"&gt;FYI, I’m not a marketing guy anyway so maybe it’s hard for me to convenience you. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;Please post your feedback. &lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-9211293207257923415?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/9211293207257923415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-development-environment.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/9211293207257923415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/9211293207257923415'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-development-environment.html' title='SharePoint Development Environment: Virtual Machine Or Virtual Hard Disk (VHD) with Dual boot'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_o7Td6KCGNTA/TbUzgzmKIBI/AAAAAAAAAr4/b8BbtFvdmqQ/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6328673102868927967</id><published>2011-04-24T06:41:00.000+02:00</published><updated>2011-04-24T06:43:22.392+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Office 365'/><category scheme='http://www.blogger.com/atom/ns#' term='Cloud'/><title type='text'>Office 365 Beta: Move to Cloud…</title><content type='html'>&lt;p&gt;I’ve got the chance to test the Office 365 beta. After registering for the office 365, I’ve found it provides three services on the cloud as shown in the image below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Exchange Online (Outlook in the image below)&lt;/li&gt;    &lt;li&gt;Lync Online&lt;/li&gt;    &lt;li&gt;SharePoint Online (Team site in the image below)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TbOqY1FeH8I/AAAAAAAAArs/7lMZwpnJYXA/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TbOqaEvrbsI/AAAAAAAAArw/wGJUNZR0GQo/image_thumb%5B1%5D.png?imgmax=800" width="583" height="462" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Figure 1: Three services provided by Office 365 (Beta).&lt;/p&gt;  &lt;p&gt;So Office 365 is all about collaboration. How we collaborate in these days in enterprise environment? &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Send mails&lt;/li&gt;    &lt;li&gt;Text Chat, Voice Chat or Video conferencing etc.&lt;/li&gt;    &lt;li&gt; Share Documents/files in collaboration&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All these features are provided by Office 365. As usually, without Office 365, we need to setup Exchange locally in office, we need to setup some kind of communication software (like gtalk, skype etc). Also for collaboration or file sharing we need to use different custom solutions. However using Office 365, local installation and maintenance of these servers/solutions will not be necessary.&lt;/p&gt;  &lt;p&gt;Also with the Microsoft Office Word, Excel, PowerPoint and OneNote in the cloud (with Office 365 beta), separate license of Microsoft Office is not required. SharePoint Online provides these Office services and also provides a public site as part of the Office 365 package.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;So why Office 365? Once reason is cost. Local installation/maintenance of server/infrastructure is not required. No separate license of Microsoft Office is required. Another reason is manageability, Office 365 puts all these three services (Exchange Online, Lync Online and SharePoint Online) in a single place to manage. This is a great relief for Admin as he can manage any issues from a single point. Disaster recovery is another reason to move to cloud. Office 365 ensures maximum availability of the service.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6328673102868927967?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6328673102868927967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/office-365-beta-move-to-cloud.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6328673102868927967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6328673102868927967'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/office-365-beta-move-to-cloud.html' title='Office 365 Beta: Move to Cloud…'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_o7Td6KCGNTA/TbOqaEvrbsI/AAAAAAAAArw/wGJUNZR0GQo/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5526990694066102752</id><published>2011-04-05T10:58:00.000+02:00</published><updated>2011-04-06T06:34:41.426+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>All About List/Site Definition– Part III: Site Definition Provisioning</title><content type='html'>&lt;p&gt;In the last two posts (&lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-2010-create-site-definition.html" target="_blank"&gt;Part I&lt;/a&gt; and &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-ii.html" target="_blank"&gt;Part II&lt;/a&gt;), I had described on creating list definition/instance and how to attach the list definition and list instance with site definition. In this post I would go a bit farther and describe on site provisioning.&lt;/p&gt;  &lt;p&gt;If you have followed my last two posts on this topic and developed a site definition and then created a site with that site definition, you will find the new site has nothing but the custom lists you have defined in the site definition. But in most cases we want a custom site definition alike Team Site definition, lets say, and then we want few more custom lists added to the team site definition. So in a sense we want to extend or inherit the built-in Team Site definition. &lt;font style="background-color: #ffff00"&gt;So the requirement is:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;Requirement 1&lt;/strong&gt;:we want our custom site definition just like Team Site Definition&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;Requirement 2&lt;/strong&gt;: but we want few more custom lists/libraries added&lt;/font&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s discuss how to meet the requirements.&lt;/p&gt;  &lt;h4&gt;Site Provisioning&lt;/h4&gt;  &lt;p&gt;In SharePoint, you can hook the site creation (known as site provisioning) event. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 1 - Create Custom Site Provision Provider&lt;/u&gt;&lt;/strong&gt;: You need to create a class which will inherit from abstract class “Microsoft.SharePoint.SPWebProvisioningProvider” . Then override the method Provision. In this Provision method you need to apply the template you want to use for your custom site definition. For your information, if you use your own site provision provider, then site will be crated with blank template and in this Provision method you need to explicitly apply the site template as shown below:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MySiteProvisioner:SPWebProvisioningProvider&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Provision(SPWebProvisioningProperties props)&lt;br /&gt;    {&lt;br /&gt;        var web = props.Web;&lt;br /&gt;        &lt;span style="color: #008000"&gt;//apply team site template.&lt;/span&gt;&lt;br /&gt;        web.ApplyWebTemplate(SPWebTemplate.WebTemplateSTS);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
  &lt;strong&gt;Code Snippet 1: Applying Web Template in Custom Site Provision Provider.&lt;/strong&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;So basically in the above code snippet, I’m using Team Site Template whereas user selected the custom site template (developed by me). Few points to notice about Custom Site Provision Provider:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you custom site provision provider then the site will be created with blank template &lt;/li&gt;

  &lt;li&gt;Since site will be created with blank template, you need to specify the template to use for site creation by using SPWeb.ApplyWebTemplate() in Proivision method of your custom Provision provider. &lt;/li&gt;

  &lt;li&gt;You can activate features in Provision method after applying web templates. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So in code snippet 1, I’ve applied team site template and it was my Reqirement 1. My second requirement was to create custom list/libraries on site creation. If you can remember from my second post on this series of article that I had developed two features: One for custom list definition and another for custom list instance. Since list definition feature is site collection scoped, we don’t need to activate this feature on site creation. Rather we need to activate the list creation feature on site creation so that the custom list gets created. Once list creation feature is activated in any site, the custom list associated with the feature will be created. So I’ve shown the modified version of code from Code Snippet1 to activate features:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MySiteProvisioner : SPWebProvisioningProvider&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Provision(SPWebProvisioningProperties props)&lt;br /&gt;    {&lt;br /&gt;        var web = props.Web;&lt;br /&gt;        &lt;span style="color: #008000"&gt;//apply team site template.&lt;/span&gt;&lt;br /&gt;        web.ApplyWebTemplate(SPWebTemplate.WebTemplateSTS);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;//activate list instance feature&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; listInstaceFeatureId = &lt;span style="color: #006080"&gt;&amp;quot;161c4ebd-97b7-4dff-9734-c930434d3e95&amp;quot;&lt;/span&gt;;&lt;br /&gt;        web.Features.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Guid(listInstaceFeatureId));&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&lt;strong&gt;Code Snippet 2: Applying new web template and activate feature in Site Provision Provider&lt;/strong&gt; 

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;So the provision provider shown in code snippet 2 is ready to go. Now we need to associate this provision provider with our custom site definition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 2 - Associate custom site provision provider with site definition&lt;/u&gt;&lt;/strong&gt;: To associate the provision provider with site definition, open the webtemp_SiteDefinitionName file and add two properties ProvisionAssembly and ProvisionClass as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TZrZ9bEkO-I/AAAAAAAAArg/3MKTATPRj2E/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TZrZ_GncvsI/AAAAAAAAArk/Qkptk2Kxb_E/image_thumb%5B1%5D.png?imgmax=800" width="745" height="206" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Figure 1: Specify the provision attributes in Site Template file.&lt;/p&gt;

&lt;p&gt;As shown in the Figure 1, the ProvisionAssembly value is set to a Visual Studio token ($SharePoint.Project.AssemblyFullName$) which will be replace with Project namespace by Visual Studio. However if you are using non-SharePoint project template in Visual Studio then you can use the full namespace in ProvisionAssembly instead of the token. The ProvisionClass is the full name of the custom provision provider. The full xml is give below so that you can easily copy/paste.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt;?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Templates&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:ows&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Microsoft SharePoint&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Template&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BlogSite&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;100000&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Configuration&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BlogSite&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Hidden&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;FALSE&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ImageUrl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;/_layouts/images/CPVW.gif&amp;quot;&lt;/span&gt; &lt;br /&gt;                   &lt;span style="color: #ff0000"&gt;ProvisionAssembly&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;$SharePoint.Project.AssemblyFullName$&amp;quot;&lt;/span&gt;&lt;br /&gt;                   &lt;span style="color: #ff0000"&gt;ProvisionClass&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BlogTest.SharePoint.Provisioning.MySiteProvisioner&amp;quot;&lt;/span&gt;&lt;br /&gt;                   &lt;span style="color: #ff0000"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BlogSite&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DisplayCategory&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Blogs&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Configuration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Template&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Templates&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code Snippet 3: Site Template xml file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now you are done. You can now deploy the SharePoint solution and try to create a new site with the custom site definition. You can check if your custom provision provider is used by attaching the debugger with w3wp and setting a breakpoint in Provision method.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;I’m not sure if this is the last post of this series but if I get interesting topics later, I’m hoping to write another post.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5526990694066102752?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5526990694066102752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-iii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5526990694066102752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5526990694066102752'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-iii.html' title='All About List/Site Definition– Part III: Site Definition Provisioning'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_o7Td6KCGNTA/TZrZ_GncvsI/AAAAAAAAArk/Qkptk2Kxb_E/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-2592975409122952800</id><published>2011-04-04T11:05:00.000+02:00</published><updated>2011-04-05T11:01:47.389+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>All About List/Site Definition– Part II: Create Site Definition and Staple list definition/instance Features</title><content type='html'>&lt;p&gt;In the &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-2010-create-site-definition.html" target="_blank"&gt;first part of this series of posts&lt;/a&gt; I had described on how to develop list definition and list instance. In this post I’ll explain how to use those list definition and list instance with site definition so that the list item is created on new site creation. Just to recall, in the first post, I had got two features that I need to active on site creation.&lt;/p&gt;  &lt;p&gt;Now you have your list definition and list instance ready (with two features). Now you need to create a site definition. To create a site definition to an existing SharePoint Project you need to install &lt;a href="http://cksdev.codeplex.com/" target="_blank"&gt;Community Kit for SharePoint: Development Tools edition&lt;/a&gt; visual studio extension.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step1: Add the site definition in the Project:&lt;/u&gt;&lt;/strong&gt; Click Add new item and from the Add new item dialog click “Blank Site Definition (CKSDev)” as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TZmKDPjtcTI/AAAAAAAAArI/x8q-JPR0oD0/s1600-h/image_thumb512.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image_thumb51" border="0" alt="image_thumb51" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TZmKEUYJpzI/AAAAAAAAArM/SGTums3DRl0/image_thumb51_thumb.png?imgmax=800" width="705" height="527" /&gt;&lt;/a&gt;e &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Add Blank Site definition item (Need to install CKSDev VS extension)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once you have added the Blank Site Definition, you will find three files are added in the project. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 2: Modify webtemp file&lt;/u&gt;&lt;/strong&gt;: You can find a file named like webtemp_sitedefinition in the site template folder. This file defines the template names, title, groups etc. Open the file and modify the description and displaycategories. However, don’t change the template name in the editor as the template name in this file related to template folder in the solution explorer as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZmKFq29CGI/AAAAAAAAArQ/rA98EH7GRgE/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TZmKGkTTFdI/AAAAAAAAArU/39TjzJ3PaEc/image_thumb%5B1%5D.png?imgmax=800" width="848" height="403" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Template file editing&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 3: Modify Onet.xml file:&lt;/u&gt;&lt;/strong&gt; One of the file is Onet.xml which is the key player in customization. If you can remember from &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-2010-create-site-definition.html" target="_blank"&gt;part I of this series of post&lt;/a&gt;, that we had two features: one was for list definition scoped at site level and another was for list instance scoped at web level. Open the Onet.xml file and add the list definition and list instance feature IDs in SiteFeatures and WebFeatures section correspondingly as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZmKHdQqUYI/AAAAAAAAArY/KW3g3UhsICc/s1600-h/image_thumb912.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image_thumb91" border="0" alt="image_thumb91" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TZmKI1MvTHI/AAAAAAAAArc/T7TK9tc6uk4/image_thumb91_thumb.png?imgmax=800" width="790" height="366" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Features to be activated defined in Site Definition&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;And you are done! Now build the solution and deploy. Once deployment done, try to create a site with the new site template, if everything works out then in the new site you will find your list created.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the next part I’ll explain more about Provisioning the site. &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-iii.html" target="_blank"&gt;The next part is here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-2592975409122952800?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/2592975409122952800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-ii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2592975409122952800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2592975409122952800'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-ii.html' title='All About List/Site Definition– Part II: Create Site Definition and Staple list definition/instance Features'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_o7Td6KCGNTA/TZmKEUYJpzI/AAAAAAAAArM/SGTums3DRl0/s72-c/image_thumb51_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5240707776015992503</id><published>2011-04-04T10:11:00.000+02:00</published><updated>2011-04-05T11:02:51.341+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>All About List/Site Definition– Part I: Create List Definition/Instance with Visual Studio 2010</title><content type='html'>&lt;p&gt;Let’s say you need to create a site definition which will satisfy the following requirements:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Define List Definition/Instance (Part I) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-ii.html" target="_blank"&gt;Define Site definition (Part II)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ranaictiu-technicalblog.blogspot.com/2011/04/all-about-listsite-definition-part-iii.html" target="_blank"&gt;Activate some features on site creation using Site Provision (Part III)&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Your client wants to have a site definition that will add a site template in the ‘create web site’ list and when user will create a site based on the site definition, a list will be created and few features will be activated. In this post I’ll focus on creating a list definition and list instance. &lt;/p&gt;  &lt;h4&gt;Create list definition and List Instance&lt;/h4&gt;  &lt;p&gt;&lt;u&gt;&lt;strong&gt;Step 1: Add List Definition and List Instance to the project&lt;/strong&gt;:&lt;/u&gt; To create a list definition along with list instance add a List Definition item in SharePoint Project as shown below. &lt;strong&gt;For easy understanding, you can put Def at the end of the list definition name&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl9c9UUcZI/AAAAAAAAApc/eM6Yk1fbNGw/s1600-h/image15.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9fK_E7kI/AAAAAAAAApg/zceP-gQNn5k/image_thumb7.png?imgmax=800" width="708" height="560" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Create List Definition item&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Later you’ll be prompted for list name, list definition type and ‘if a list instance will be created’ option as shown below. You may need to modify the list definition name, and list definition type. Also make sure the ‘Add a list instance for this list definition’ is selected as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TZl9gWAMR7I/AAAAAAAAApk/Du-HpzfX9RU/s1600-h/image19.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9hk5SqOI/AAAAAAAAApo/O7nafBd_o5c/image_thumb9.png?imgmax=800" width="604" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: List Definition Creation dialog&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 2: Set List Instance Name and Title:&lt;/u&gt; &lt;/strong&gt;After the list definition and list instance are added to the project, you will find the list instance name is generated automatically which you want to rename as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TZl9ikDonbI/AAAAAAAAAps/Z72hQnZ9FJI/s1600-h/image23.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl9kf7WbHI/AAAAAAAAApw/XD6NCsTWkKg/image_thumb11.png?imgmax=800" width="469" height="228" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Rename auto-generated list instance name&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Then focus on modifying the List Instance elements.xml file. At least modify the list title and URL as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl9lsQ53CI/AAAAAAAAAp0/6HBG6ycSQqc/s1600-h/image27.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl9mVn28AI/AAAAAAAAAp4/JCI2cKpHA88/image_thumb13.png?imgmax=800" width="505" height="164" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Rename list instance title and url in elements.xml file of the list instance.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now you have added the list definition and list instance and your next step is to define the list&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 3: Define Template Type&lt;/u&gt;&lt;/strong&gt;: Now you have added the list definition and list instance. First of all make sure you have put a type id for list definition and used that type id in list instance as shown below. I’ve set the template type in the left file (list definition) as (Type=10001) and the same type is used in the right file (list instance) as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TZl9nnnrqII/AAAAAAAAAp8/4Z4ZdX4TzYw/s1600-h/image43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TZl9pKX-DqI/AAAAAAAAAqA/FL3sezSorYk/image_thumb21.png?imgmax=800" width="703" height="431" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 5: Template Type id in List definition and list instance Elements.xml file (side by side)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 4: Add fields in the list definition&lt;/u&gt;: &lt;/strong&gt;Now you are ready to add fields to the list definition. For this open the Schema.xml file under list definition folder and move the position between &amp;lt;Fields&amp;gt;&amp;lt;/Fields&amp;gt; as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9qIL8-6I/AAAAAAAAAqE/hR5iL7ZjNXs/s1600-h/image39.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9rUzH_UI/AAAAAAAAAqI/KdYtcLoibng/image_thumb19.png?imgmax=800" width="507" height="272" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 6: Add Fields in list definition&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So you are ready to add fields but it’ll be tough to add all fields just by typing manually. There’s trick I use often:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a test list with the required fields &lt;/li&gt;    &lt;li&gt;Save the list as template &lt;/li&gt;    &lt;li&gt;Download the list template from template gallery. &lt;/li&gt;    &lt;li&gt;Rename the template file extension from .stp to .cab &lt;/li&gt;    &lt;li&gt;Open the cab file and extract the Manifest.xml file. &lt;/li&gt;    &lt;li&gt;Finally I take the field definitions from the Manifest.xml file &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 5: Add fields to default view:&lt;/u&gt;&lt;/strong&gt; In this step, you will add the fields to the default view (or any other view you want). If you take a look at the schema.xml file you will find more than one views are defined in the schema file. However, the view with DefaultView=”True” is the default view. Normally the view with BaseViewID 1 is the default view as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9s5Mh6tI/AAAAAAAAAqM/42Y3FU293U0/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl_mngO7FI/AAAAAAAAAqU/139oysNyngM/image_thumb11%5B1%5D.png?imgmax=800" width="822" height="322" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 7: Default View with BaseViewID property value set to 1&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So you have found the default view and now you need to add the field reference in the default view. As shown below, you can either user GUID or Field Name for referencing a field in ViewFields:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl_n9WMHRI/AAAAAAAAAqY/23HQRxckKj0/s1600-h/image7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl_pba7IQI/AAAAAAAAAqc/lC9H_jx2l_0/image_thumb3.png?imgmax=800" width="728" height="402" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 8: Add Field Ref in ViewField either by Field Name or ID&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Though you can use either Field Name or ID for referencing a field in ViewFields, I prefer ID as the name can be changed/modified or XML encoded.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 6: Associate List definition and list instance with Two Features&lt;/u&gt;&lt;/strong&gt;: Now you have two elements files: One is for list definition and another one is for list instance. With SharePoint architecture in mind, we need to activate the list definition in Site collection. Whereas the list instance needs to be created in individual web. So add two features and associate the elements.xml (FYI, elements.xml file can be associated with features) with features.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We need to add a feature with site collection scope, and need to associate the list definition with that feature. In my case the feature ID is 574b2a16-b01d-4e30-97ed-d1c4a5aa37ea. &lt;font style="background-color: #ffff00"&gt;You are not done yet with the list instance, you need to take the feature id (in which the list definition is attached) and put the value in List Instance elements.xml file as shown below&lt;/font&gt;:       &lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl_qtrdADI/AAAAAAAAAqg/4vp2GtVkdQA/s1600-h/image4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TZl_r_swywI/AAAAAAAAAqk/fmPb5uuHb8k/image_thumb1.png?imgmax=800" width="691" height="226" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 9: List Instance Elements.xml file with list definition Feature ID&lt;/strong&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;We need to add another feature with web scope and need to associate the list instance with the feature &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The following Figure shows the List Definition Feature:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TZl_syBLNiI/AAAAAAAAAqo/iAYLPJDy8fM/s1600-h/image12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TZl_uXAnudI/AAAAAAAAAqs/4tErGVab4bw/image_thumb5.png?imgmax=800" width="714" height="280" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 10: List Definition Feature with Site Collection Scope (left circle) and ListDef item added (right circle)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The following figure shows the List Instance Feature:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TZl_vEeubUI/AAAAAAAAAqw/I3v5a-hxFtc/s1600-h/image16.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TZl_xSoBVoI/AAAAAAAAAq0/RJ1Rh7DjIes/image_thumb71.png?imgmax=800" width="717" height="285" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 11: List Instance Feature with Web scoped (left circle) and list instance item added (right circle)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;So after this steps we get two final outputs (i.e., two features) that will be used in site definition. So collect the two feature IDs (you can get the feature ID by selecting and then opening the properties window). In my case the List Definition feature ID was &lt;strong&gt;&lt;font color="#ff0000"&gt;574b2a16-b01d-4e30-97ed-d1c4a5aa37ea&lt;/font&gt;&lt;/strong&gt; and List Instance Feature ID was &lt;strong&gt;&lt;font color="#ff0000"&gt;161c4ebd-97b7-4dff-9734-c930434d3e95&lt;/font&gt;&lt;/strong&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;Until now you have developed one list definition, one list instance and two features: one for list definition and one for list instance. in the next post I’ll explain how to staple these list definition/instance with site definition.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5240707776015992503?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5240707776015992503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-2010-create-site-definition.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5240707776015992503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5240707776015992503'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/04/sharepoint-2010-create-site-definition.html' title='All About List/Site Definition– Part I: Create List Definition/Instance with Visual Studio 2010'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_o7Td6KCGNTA/TZl9fK_E7kI/AAAAAAAAApg/zceP-gQNn5k/s72-c/image_thumb7.png?imgmax=800' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6155550900320606383</id><published>2011-03-09T09:55:00.000+01:00</published><updated>2011-09-07T06:13:39.074+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Client OM'/><title type='text'>SharePoint 2010 Client Object Model: Manipulate Choice, Lookup field</title><content type='html'>&lt;p&gt;After my few posts on Client Object Model, I had come to questions on how to manipulate choice and lookup field. I’ve tried to explain a bit on how you can manipulate these field values with Client Object Model.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Manipulate Choice Field Value (Single Choice)&lt;/h4&gt;  &lt;p&gt;You can manipulate the single choice field value as like string. For example, let’s consider a field, ProductStatus in Product list. The field values might be “In Stock, Out of Stock, Invalid” as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TXdAkqJNgKI/AAAAAAAAAow/fm7raCuQAio/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TXdAmCI17kI/AAAAAAAAAo0/75deIYVS5BQ/image_thumb%5B1%5D.png?imgmax=800" width="321" height="566" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Figure 1: Single Choice Field (ProductStatus) in product list.&lt;/p&gt;  &lt;p&gt;To access the value of the field using Client Object Model, you can use code shown below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Get Field value&lt;/strong&gt;: You can just get the field value as string       &lt;br /&gt;      &lt;div id="codeSnippetWrapper"&gt;       &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;var productStatus = productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductStatus&amp;quot;&lt;/span&gt;].ToString();&lt;/pre&gt;

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Set Field value&lt;/strong&gt;: You can use any of the following statement to set the field value 

    &lt;br /&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductStatus&amp;quot;&lt;/span&gt;] = &lt;span style="color: #006080"&gt;&amp;quot;In Stock&amp;quot;&lt;/span&gt;;&lt;br /&gt;productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductStatus&amp;quot;&lt;/span&gt;] = &lt;span style="color: #006080"&gt;&amp;quot;Out of Stock&amp;quot;&lt;/span&gt;;&lt;br /&gt;productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductStatus&amp;quot;&lt;/span&gt;] = &lt;span style="color: #006080"&gt;&amp;quot;Invalid&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Manipulate Choice Field Value (Multiple Choice)&lt;/h4&gt;

&lt;p&gt;If the choice field support multiple values then you need to use string array to manipulate field values. For example, consider there’s a field ‘product types’&amp;#160; in product list whose values can be Foods, electronics, Cars etc. Also consider the field values can be multiple, that’s mean a product types can be more than one type. The following figure shows the field&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TXdAnMRS7FI/AAAAAAAAAo4/VymYLpb45TM/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TXdAoOoa86I/AAAAAAAAAo8/AsE2F2vtliU/image_thumb%5B5%5D.png?imgmax=800" width="304" height="558" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 2: Multiple Choice Field&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In that case you need string array to access the multiple choice field value as shown as shown below:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Get Field Value: 
    &lt;br /&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;var productTypes = (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[]) (productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductType&amp;quot;&lt;/span&gt;]);&lt;/pre&gt;

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;Set Field Value: 
    &lt;br /&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;productItem[&lt;span style="color: #006080"&gt;&amp;quot;ProductType&amp;quot;&lt;/span&gt;] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] { &lt;span style="color: #006080"&gt;&amp;quot;Furniture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Toys&amp;quot;&lt;/span&gt; };&lt;/pre&gt;

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Manipulate Lookup Field Value&lt;/h4&gt;

&lt;p&gt;To manipulate lookup field you need to use the code as shown below:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Get Field Value: 
    &lt;br /&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;var lookupFieldValue = (productItem[&lt;span style="color: #006080"&gt;&amp;quot;FieldName&amp;quot;&lt;/span&gt;] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; FieldLookupValue);&lt;/pre&gt;

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;Set Field Value 
    &lt;br /&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;div id="codeSnippetWrapper"&gt;
        &lt;div id="codeSnippetWrapper"&gt;
          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;//100 here is the lookup field id value&lt;/span&gt;&lt;br /&gt;productItem[&lt;span style="color: #006080"&gt;&amp;quot;FieldName&amp;quot;&lt;/span&gt;] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FieldLookupValue(){LookupId = 100};&lt;/pre&gt;

          &lt;br /&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The FieldLookupValue is part of SharePoint Client OM .&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6155550900320606383?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6155550900320606383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-client-object-model.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6155550900320606383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6155550900320606383'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-client-object-model.html' title='SharePoint 2010 Client Object Model: Manipulate Choice, Lookup field'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TXdAmCI17kI/AAAAAAAAAo0/75deIYVS5BQ/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8821567795361686856</id><published>2011-03-06T10:02:00.000+01:00</published><updated>2011-03-08T05:37:39.792+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Create Custom WCF Service</title><content type='html'>&lt;p&gt;In SharePoint 2007, creating a custom Web Service was not so easy. However, asp.net web services are obsolete in SharePoint 2010. Rather new and recommended approach is to develop WCF Service. So the question comes up, “How much difficult it is to create a custom WCF service in SharePoint 2010?”. I’m going to answer the question just right in this blog.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Install CKS development tools edition&lt;/h4&gt;  &lt;p&gt;For showing how easily you can develop your own Custom WCF Service in SharePoint 2010, I’m going to use a open source Visual Studio 2010 extension know as &lt;a href="http://cksdev.codeplex.com/" target="_blank"&gt;Community Kit for SharePoint: Development Tools Edition&lt;/a&gt;. This tool will make the WCF service development much easier. It’ll automate tasks that you would have to do manually. There are two version of the extensions: One for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/a346880f-2d29-47a6-84a2-f2d568dd6997/" target="_blank"&gt;SharePoint Foundation&lt;/a&gt; and another one is for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/ee876627-962c-4c35-a4a6-a4d89bfb61dc/" target="_blank"&gt;SharePoint Server&lt;/a&gt;. Download the appropriate version and install.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Create WCF Service&lt;/h4&gt;  &lt;p&gt;Once you installed the CKSDev Visual Studio extension, you can open a SharePoint Project. In the SharePoint Project, right click on the project and try to add a new item. In the “Add New Item” dialog, you will find some new items added by CKSDev Visual Studio extension. Please select the option “WCF Service (CKSDev)” for new item as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TXNNrhHWH6I/AAAAAAAAAoI/Chd-29zMakI/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TXNNtRtb74I/AAAAAAAAAoM/I_9xpogMsB4/image_thumb%5B1%5D.png?imgmax=800" width="672" height="496" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: ‘Add New WCF Service’ option ‘add new item’ dialog&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once you add the WCF Service, two files will be added by the dialog. One is the service interface and another is the Service itself.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Modify Service Types&lt;/h4&gt;  &lt;p&gt;As &lt;a href="http://msdn.microsoft.com/en-us/library/ff521586.aspx" target="_blank"&gt;defined in MSDN&lt;/a&gt;, there are three different service types. Most of the time you need SOAP service. But if you need REST or ADO.NET Data service you can modify the service types by modifying the service factory as sown in the figure 2. The following table shows the three service types and their service factory name.&lt;/p&gt;  &lt;table border="1" width="711"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;th width="150"&gt;         &lt;p&gt;Service Type&lt;/p&gt;       &lt;/th&gt;        &lt;th width="340"&gt;         &lt;p&gt;Service Factory&lt;/p&gt;       &lt;/th&gt;        &lt;th width="219"&gt;         &lt;p&gt;Description&lt;/p&gt;       &lt;/th&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="150"&gt;         &lt;p&gt;SOAP service&lt;/p&gt;       &lt;/td&gt;        &lt;td width="340"&gt;         &lt;p&gt;&lt;span&gt;&lt;span class="input"&gt;MultipleBaseAddressBasicHttpBindingServiceHostFactory&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td width="219"&gt;         &lt;p&gt;Basic HTTP binding must be used, which creates endpoints for a service based on the basic HTTP binding.&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="150"&gt;         &lt;p&gt;REST Service&lt;/p&gt;       &lt;/td&gt;        &lt;td width="340"&gt;         &lt;p&gt;&lt;span&gt;&lt;span class="input"&gt;MultipleBaseAddressWebServiceHostFactory&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td width="219"&gt;         &lt;p&gt;The service factory creates endpoints with Web bindings.&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="150"&gt;         &lt;p&gt;ADO.NET Data Service&lt;/p&gt;       &lt;/td&gt;        &lt;td width="340"&gt;         &lt;p&gt;&lt;span&gt;&lt;span class="input"&gt;MultipleBaseAddressDataServiceHostFactory&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td width="219"&gt;         &lt;p&gt;A data service host factory can be used.&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;When you create service with CKSDev tool, the default service generated is SOAP service. If you want to change the service type, please modify the factory in .svc file as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TXNNup7XHgI/AAAAAAAAAoQ/oMkgbW9-EEY/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TXNNv4zsvPI/AAAAAAAAAoU/lYQMmyDAzIc/image_thumb%5B3%5D.png?imgmax=800" width="717" height="105" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Service Factory defined in SVC file.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Deploy the Service&lt;/h4&gt;  &lt;p&gt;Once you are done with the service development, you are ready to deploy. But where you want to deploy the service? By default SharePoint service are kept in &lt;strong&gt;ISAPI&lt;/strong&gt; directory. However, CKSDev deploy the service in &lt;strong&gt;ISAPI\ProjectNameSpace&lt;/strong&gt; path as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TXNNw9RpYjI/AAAAAAAAAoY/6JaoYwabH64/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TXNNyK_Jd0I/AAAAAAAAAoc/Od6mBxYrgIk/image_thumb%5B5%5D.png?imgmax=800" width="579" height="483" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Service deployment location&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once you define the service deployment location as shown in the figure 3, you can deploy the solution.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Access the Custom WCF Service&lt;/h4&gt;  &lt;p&gt;After Service deploy, you need to use the service in another projects. First try to access the service in browser. &lt;font color="#ff0000"&gt;But remember you need to access the MEX endpoint either you will not get the service accessible in browser&lt;/font&gt;. To access the MEX endpoint, you should add “&lt;strong&gt;/MEX&lt;/strong&gt;” at the end of the service name as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TXNNy0MPNyI/AAAAAAAAAog/awclecCVFZs/s1600-h/image%5B15%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TXNNz9r90gI/AAAAAAAAAok/dw4mAZ_xX3g/image_thumb%5B7%5D.png?imgmax=800" width="539" height="167" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Access WCF Service MEX endpoint.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Finally try to add the service reference in a project using Visual Studio’s ‘Add Service Reference’ dialog as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TXNN0ljwVFI/AAAAAAAAAoo/B_8NNM6qb2M/s1600-h/image%5B19%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TXNN2J5TVcI/AAAAAAAAAos/rmxqKlL8Wt4/image_thumb%5B9%5D.png?imgmax=800" width="670" height="440" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 5: Add Service Reference&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Conclusion&lt;/h4&gt;  &lt;p&gt;So the steps described in this post are pretty simple:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Make sure you have downloaded and installed CKSDev Visual Studio extension. &lt;/li&gt;    &lt;li&gt;Create a WCF Service (CKSDev) in the project. And if necessary, modify the service type &lt;/li&gt;    &lt;li&gt;Deploy the solution and if necessary, change the deployment path. &lt;/li&gt;    &lt;li&gt;Access the service MEX endpoint. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You are done. Pretty simple, I think.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8821567795361686856?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8821567795361686856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-create-custom-wcf.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8821567795361686856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8821567795361686856'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-create-custom-wcf.html' title='SharePoint 2010: Create Custom WCF Service'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_o7Td6KCGNTA/TXNNtRtb74I/AAAAAAAAAoM/I_9xpogMsB4/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8441586848558923699</id><published>2011-03-02T09:53:00.000+01:00</published><updated>2011-03-02T10:05:07.590+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Select the best option for accessing SharePoint data from clients</title><content type='html'>&lt;p&gt;There are few ways you can access data stored in SharePoint from a non-SharePoint application.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Client Object Model (OM): SharePoint provides three flavors of Client OM (Managed, EcmaScript and Silverlight) &lt;/li&gt;    &lt;li&gt;Asp.Net web Service: The legacy web services of SharePoint 2007 are still supported for backward compatibility. We should try to avoid using these legacy web services for green field development. &lt;/li&gt;    &lt;li&gt;REST-based Service (SharePoint 2010 Provided): SharePoint 2010 provides new set of WCF service which is REST enabled. &lt;/li&gt;    &lt;li&gt;Custom WCF Service: There’s another option of developing custom WCF service of your own. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s discuss which options you’ll take into account in selecting the best suitable options for your applications:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Client Object Mode (OM)&lt;/h4&gt;  &lt;p&gt;I think Client Object Model is the best choice in most of the cases. If you want to access SharePoint data from SharePoint webpart, then you can use Client OM (EcmaScript) to access data in SharePoint. If you are trying to access SharePoint data from Silverlight then you can use&amp;#160; Client OM for Silverlight. And most of all you can use Managed Client OM, in supported .net language to access SharePoint data. &lt;/p&gt;  &lt;p&gt;So Client OM is surely your first choice. But in many cases you can’t use Client OM, especially in cases where you are trying to access SharePoint data from non-Microsoft platform, like Java. Also if your migrating your application from SharePoint 2003/2007 and you are already using asp.net web service, then you don’t have much choice but to use the legacy web services.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Asp.Net Web Services&lt;/h4&gt;  &lt;p&gt;SharePoint 2007 comes with built-in web services. These legacy web services are still in SharePoint to support backward-compatibility but whenever you have the option to avoid them, please do so. The only reason I see to use these legacy web services is for applications migrating from pre-SharePoint 2010 to SharePoint 2010. Maybe this is the last version of SharePoint with the support of the legacy web services (at least I hope so). Few legacy asp.net services are listed below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;/_vit_bin/Lists.asmx&lt;/li&gt;    &lt;li&gt;/_vit_bin/Copy.asmx&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;SharePoint WCF Services (REST-based)&lt;/h4&gt;  &lt;p&gt;The new addition of extensibility point in SharePoint 20l10 is WCF services. If you are planning to manipulate SharePoint data from different platforms, like Java, then these WCF services are the excellent option to go with. If you install WCF data service updates, then these WCF services enable REST-based request processing. For more information on REST-based interface of SharePoint WCF services, please follow the &lt;a href="http://msdn.microsoft.com/en-us/library/ff521587.aspx" target="_blank"&gt;MSDN link&lt;/a&gt;. You can also use these WCF services from .net applications. You can get the &lt;a href="http://msdn.microsoft.com/en-us/library/ff521583.aspx" target="_blank"&gt;help from MSDN&lt;/a&gt; on how to use these WCF services in .net applications. Few new WCF services available in SharePoint 2010, are listed below:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;/_vti_bin/ListData.svc&lt;/li&gt;    &lt;li&gt;/_vti_bin/Client.svc&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Custom WCF Service&lt;/h4&gt;  &lt;p&gt;In real world, we rarely happy with out of the box functionalities. We need to customize a lot to happy our clients. Similarly we may need to develop our own WCF services. Writing a custom asp.net web service in SharePoint 2007 was a very difficult task. But in SharePoint 2010, writing a custom WCF service is much easier now. If you install &lt;a href="http://cksdev.codeplex.com/" target="_blank"&gt;Community Kit for SharePoint (CKS)&lt;/a&gt; Visual Studio extension from CodePlex, you can develop a custom SharePoint Service easily. There’s also manual process of developing custom WCF Server in SharePoint described in MSDN: &lt;a href="http://msdn.microsoft.com/en-us/library/ff521586.aspx" target="_blank"&gt;WCF Services in SharePoint&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ff521581.aspx" target="_blank"&gt;Creating Custom WCF Service&lt;/a&gt;. I’ll try to post more details on how to use CKS add-in to develop custom WCF service in another post. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8441586848558923699?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8441586848558923699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-select-best-option-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8441586848558923699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8441586848558923699'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/03/sharepoint-2010-select-best-option-for.html' title='SharePoint 2010: Select the best option for accessing SharePoint data from clients'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6798547866464278843</id><published>2011-02-28T23:56:00.000+01:00</published><updated>2011-02-28T09:56:33.772+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Approve/Reject Content Programmatically with SharePoint Object Model</title><content type='html'>&lt;p&gt;In SharePoint 2010, you can modify the moderation status (approve/reject) of an item programmatically. Once you have got the ListItem, you can access the ModerationInformation properties to know the status, as shown below:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;SPListItem listItem = GetListItem();&lt;br /&gt;var moderationInformation = listItem.ModerationInformation;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (moderationInformation != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (moderationInformation.Status == SPModerationStatusType.Approved)&lt;br /&gt;    {         &lt;br /&gt;        &lt;span style="color: #008000"&gt;//approved     &lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (moderationInformation.Status == SPModerationStatusType.Denied)&lt;br /&gt;    {         &lt;br /&gt;        &lt;span style="color: #008000"&gt;//rejected     &lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (moderationInformation.Status == SPModerationStatusType.Draft)&lt;br /&gt;    {         &lt;br /&gt;        &lt;span style="color: #008000"&gt;//item is in edit mode and yet send to pending state.     &lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (moderationInformation.Status == SPModerationStatusType.Scheduled)&lt;br /&gt;    {         &lt;br /&gt;        &lt;span style="color: #008000"&gt;//approval is waiting to be processed by a timer service.     &lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;   &lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;However, Remember to check the ModerationInformation for null. If versioning/content approval is not enabled then the moderationinformation will be null. You can modify the moderation status by editing the moderationinformation and updating the list item as shown below:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;SPListItem listItem = GetListItem();&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (listItem.ModerationInformation != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    listItem.ModerationInformation.Status = SPModerationStatusType.Approved; &lt;br /&gt;    listItem.ModerationInformation.Comment = &lt;span style="color: #006080"&gt;&amp;quot;This is comment&amp;quot;&lt;/span&gt;; &lt;br /&gt;    listItem.Update();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Hope someone will get this useful!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6798547866464278843?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6798547866464278843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/02/sharepoint-2010-approvereject-content.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6798547866464278843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6798547866464278843'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/02/sharepoint-2010-approvereject-content.html' title='SharePoint 2010: Approve/Reject Content Programmatically with SharePoint Object Model'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5920784430563569034</id><published>2011-02-17T09:09:00.000+01:00</published><updated>2011-02-17T09:10:52.230+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Deployment'/><title type='text'>IE9 and User Agent String</title><content type='html'>&lt;p&gt;With new IE in market the web developer community has been in the danger of supporting another extra browser. Recently we have found our application is in problem with IE9. We have a client application that put some data in User Agent Post platform value in registry. From IE6 to IE8 the post platform value was passing from server to client in UserAgent. So basically we had put some value in UserAgent Post Platform in registry from a client application and from our web application we had found the value (as the post platform values are passed in User Agent from IE6 to IE8). But with IE the post platform values are not passed with User Agent automatically.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;User Agent and Pre/Post Platform value&lt;/h4&gt;  &lt;p&gt;If you are interested on how the Pre and Post Platform values works with User Agent you can visit the MSDN link: &lt;a title="http://msdn.microsoft.com/en-us/library/ms537503%28VS.85%29.aspx" href="http://msdn.microsoft.com/en-us/library/ms537503%28VS.85%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms537503%28VS.85%29.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;IE9 introduces Default User Agent and Extended User Agent&lt;/h4&gt;  &lt;p&gt;In IE9 the user agent has been divided into two parts: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Default User Agent (UA)&lt;/strong&gt;: IE9 by default will not send the pre/post platform values from client to server. So if you have some values in client’s pre and post platform then your web site will not get those values (from pre and post platform) as IE9 will not pass those values to server. However IE6 to IE8 will work as usual (i.e., pass those pre and post platform values) .&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Extended User Agent (UA)&lt;/strong&gt;: So the question is if IE9 doesn’t send the pre and post platform values by its own then how can we access the platform values? The answer to this question is simple but implementation is tricky. You can get the pre and post platform values on client side only with JavaScript by accessing &lt;em&gt;&lt;u&gt;Navigator.UserAgent&lt;/u&gt;&lt;/em&gt;. So IE9 will not take the responsibility of passing Extended UA from client to server. You need to do it by your own. You need to read the extended UA by javascript on the client side and need to pass to the server by using Hidden control or any other way.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;How to get the Pre/Post platform vales IE9?&lt;/h4&gt;  &lt;p&gt;By following javascript code you can get the pre/post platform values on client side.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&amp;lt;script type=&lt;span class="str"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;
    alert(navigator.userAgent);
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;You can get more details on this on MSDN IE blog: &lt;a title="http://blogs.msdn.com/b/ie/archive/2010/03/23/introducing-ie9-s-user-agent-string.aspx" href="http://blogs.msdn.com/b/ie/archive/2010/03/23/introducing-ie9-s-user-agent-string.aspx"&gt;http://blogs.msdn.com/b/ie/archive/2010/03/23/introducing-ie9-s-user-agent-string.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5920784430563569034?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5920784430563569034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/02/ie9-and-user-agent-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5920784430563569034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5920784430563569034'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/02/ie9-and-user-agent-string.html' title='IE9 and User Agent String'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6704070518787337338</id><published>2011-01-19T09:47:00.000+01:00</published><updated>2011-01-19T09:50:47.877+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linq to SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>U2U CAML Query Builder for SharePoint 2010?</title><content type='html'>&lt;p&gt;U2U CAML query builder is a great tool for SharePoint developer. I’ve used this tool frequently with SharePoint 2007 development. However, I’ve got into trouble with using the tool with SharePoint 2010. The tool is not updated for SharePoint 2010 yet. Though you can use U2U CAML builder with SharePoint 2010 (shown later in this post), you want to use new features of CAML (say join lists) and such new features are not supported in CAML builder. In this post I’ll show how you can generate CAML query for SharePoint 2010 using few tools and Linq query. First let’s discuss on how you can still use CAML builder to generate CAML for SharePoint 2010.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Use CAML Builder with SharePoint 2010 (I’ll not recommend)&lt;/h4&gt;  &lt;p&gt;Till now the CAML builder doesn’t support SharePoint 2010. However, you can make the tool working by using connecting via web service as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TTalR6j3ElI/AAAAAAAAAnA/QgehReJjv-0/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TTalS6hha8I/AAAAAAAAAnE/M-uqIJ6y43U/image_thumb1.png?imgmax=800" width="374" height="436" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Use CAML builder with SharePoint 2010 &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;However, you are not saved. As I mentioned already till the date I’m writing this post, the CAML builder is not updated to support SharePoint 2010. So new CAML features (like list joins) will not work in this old CAML builder.&lt;/p&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Generate CAML from Linq-to-SharePoint (Better approach)&lt;/h4&gt;  &lt;p&gt;Though you can use old CAML builder with SharePoint 2010, since the CAML builder is not updated yet, you will not get the CAML new features when you will use CAML builder. Worried? Please don’t. There’s an way out. Let me explain&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Download CKS Visual Studio Extension:&lt;/strong&gt; There’s an useful and handy Visual Studio Extension for SharePoint developers known as Community Kit for SharePoint (CKS): Development tool edition. You can download the extension for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/ee876627-962c-4c35-a4a6-a4d89bfb61dc" target="_blank"&gt;SharePoint Server&lt;/a&gt; or for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/a346880f-2d29-47a6-84a2-f2d568dd6997" target="_blank"&gt;SharePoint Foundation&lt;/a&gt;.       &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Generate Entity classes from SharePoint site:&lt;/strong&gt; Once you have installed the Community Kit for SharePoint, you can generate entity classes from Server Explorer. First open a SharePoint project in Visual Studio and then connect to the SharePoint server from Server Explorer ==&amp;gt; SharePoint Connections. Then right click on your web and click “Generate entity classes” as shown below. This will generate the entity classes in the current selected project of Visual Studio.       &lt;br /&gt;      &lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TTalUFOkuXI/AAAAAAAAAnI/y4WIk-gHYOs/s1600-h/image8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TTalVTxLUVI/AAAAAAAAAnM/IdiLu2AwXpE/image_thumb3.png?imgmax=800" width="425" height="534" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;strong&gt;Figure 2: Generate entity class from SharePoint site/web&lt;/strong&gt;       &lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Write Linq using Linq-to-SharePoint against generated entity classes:&lt;/strong&gt; Once you have generated the entity classes as described on step2, you can use Linq to SharePoint to write your logic that you want to achieve through CAML. Once you write the Linq, you can run the code and log the CAML generated from the Linq. For example I have two lists Orders and Product. I want to join two lists to get order title and product name. The Linq will look like as shown below:       &lt;br /&gt;      &lt;br /&gt;      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (var dataContext = &lt;span class="kwrd"&gt;new&lt;/span&gt; MySiteDataContext(siteUrl))
{
&lt;font style="background-color: #ffff00"&gt;    TextWriter textWriter = &lt;span class="kwrd"&gt;new&lt;/span&gt; StreamWriter(&lt;span class="str"&gt;@&amp;quot;c:\caml.txt&amp;quot;&lt;/span&gt;,&lt;span class="kwrd"&gt;false&lt;/span&gt;);
    dataContext.Log = textWriter;&lt;/font&gt;
    var result = from o &lt;span class="kwrd"&gt;in&lt;/span&gt; dataContext.Orders
                    join p &lt;span class="kwrd"&gt;in&lt;/span&gt; dataContext.Product on o.Product.Id equals p.Id
                    select &lt;span class="kwrd"&gt;new&lt;/span&gt; {OrderName = o.Title, p.ProductName};
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var v &lt;span class="kwrd"&gt;in&lt;/span&gt; result)
    {
        System.Console.WriteLine(&lt;span class="str"&gt;&amp;quot;{0}----{1}&amp;quot;&lt;/span&gt;,v.OrderName,v.ProductName);
    }
}
&lt;strong&gt;Code snippet 1: Linq query using Linq to SharePoint&lt;/strong&gt;&lt;/pre&gt;
    &lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

    &lt;br /&gt;

    &lt;br /&gt;As shown in the code snippet above, I have used the data context generated at step 2 and I have run a Linq query against two lists of the data context. The most import thing to notice in above code snippet is marked with yellow. I have instantiated a text writer (initialize with file stream) and then I had set it as the Log property of the datacontext. This will ensure that any CAML generated from the Linq query will be written in the writer. Once the query gets executed the CAML is dumped in the file (in my case C:\Caml.txt). 

    &lt;br /&gt;

    &lt;br /&gt;So for generating any complex CAML query you can first write its equivalent Linq query and then get the CAML from log. 

    &lt;br /&gt;

    &lt;br /&gt;

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Get the CAML from the Linq query: &lt;/strong&gt;After running the Linq to SharePoint query, you have got the CAML query in the log file as shown in step 3. However, you need to work a bit to make the CAML usable in SPQuery. The CAML generated from code snippet 1 is shown below: 

    &lt;br /&gt;

    &lt;br /&gt;

    &lt;br /&gt;

    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;View&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Query&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;font style="background-color: #ffff00"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Where&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;
&lt;font style="background-color: #ffff00"&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;And&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;BeginsWith&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Value&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0x0100&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;BeginsWith&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;BeginsWith&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductContentTypeId&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Value&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Lookup&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0x0100&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;BeginsWith&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;And&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;
&lt;font style="background-color: #ffff00"&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Where&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;OrderBy&lt;/span&gt; &lt;span class="attr"&gt;Override&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Query&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ViewFields&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Title&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductProductName&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ViewFields&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ProjectedFields&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductProductName&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Lookup&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;List&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ShowField&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductName&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Field&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductContentTypeId&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Lookup&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;List&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ShowField&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ProjectedFields&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Joins&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Join&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;INNER&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ListAlias&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Eq&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;RefType&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ID&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;FieldRef&lt;/span&gt; &lt;span class="attr"&gt;List&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Product&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ID&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Eq&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Join&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Joins&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;font style="background-color: #ffff00"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;RowLimit&lt;/span&gt; &lt;span class="attr"&gt;Paged&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TRUE&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;2147483647&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;RowLimit&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;View&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;strong&gt;Code snippet 2: CAML generated from Linq query of Code Snippet 1&lt;/strong&gt; 

    &lt;br /&gt;

    &lt;br /&gt;In the above code snippet, the lines marked with yellow can be modified if you want. Specially the content type in where part is put in the CAML to ensure only list items are selected. FYI, Content type 0x0100 means list item type.&amp;#160; &lt;br /&gt;

    &lt;br /&gt;

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Use CAML query in SPQuery:&lt;/strong&gt; Now you have got the CAML and you want to use the CAML in SPQuery. The following code snippet shows how I’ve used the CAML(from code snippet 2) in SPQuery: 

    &lt;br /&gt;

    &lt;br /&gt;

    &lt;pre class="csharpcode"&gt;SPQuery query = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPQuery();
query.Query = &lt;span class="str"&gt;@&amp;quot;&amp;lt;Where&amp;gt;
                    &amp;lt;And&amp;gt;
                    &amp;lt;BeginsWith&amp;gt;
                        &amp;lt;FieldRef Name='ContentTypeId' /&amp;gt;
                        &amp;lt;Value Type='ContentTypeId'&amp;gt;0x0100&amp;lt;/Value&amp;gt;
                    &amp;lt;/BeginsWith&amp;gt;
                    &amp;lt;BeginsWith&amp;gt;
                        &amp;lt;FieldRef Name='ProductContentTypeId' /&amp;gt;
                        &amp;lt;Value Type='Lookup'&amp;gt;0x0100&amp;lt;/Value&amp;gt;
                    &amp;lt;/BeginsWith&amp;gt;
                    &amp;lt;/And&amp;gt;
                &amp;lt;/Where&amp;gt;
                &amp;lt;OrderBy Override='TRUE' /&amp;gt;&amp;quot;&lt;/span&gt;;

query.ViewFields = &lt;span class="str"&gt;@&amp;quot;&amp;lt;FieldRef Name='Title' /&amp;gt;
                    &amp;lt;FieldRef Name='ProductProductName' /&amp;gt;&amp;quot;&lt;/span&gt;;
query.ProjectedFields = &lt;span class="str"&gt;@&amp;quot;&amp;lt;Field Name='ProductProductName' Type='Lookup' 
                                 List='Product' ShowField='ProductName' /&amp;gt;
                          &amp;lt;Field Name='ProductContentTypeId' Type='Lookup' 
                                 List='Product' ShowField='ContentTypeId' /&amp;gt;&amp;quot;&lt;/span&gt;;
query.Joins = &lt;span class="str"&gt;@&amp;quot;&amp;lt;Join Type='INNER' ListAlias='Product'&amp;gt;
                &amp;lt;Eq&amp;gt;
                    &amp;lt;FieldRef Name='Product' RefType='ID' /&amp;gt;
                    &amp;lt;FieldRef List='Product' Name='ID' /&amp;gt;
                &amp;lt;/Eq&amp;gt;
                &amp;lt;/Join&amp;gt;&amp;quot;&lt;/span&gt;;

query.RowLimit = 2147483647;

var list = web.Lists[&lt;span class="str"&gt;&amp;quot;Orders&amp;quot;&lt;/span&gt;];
var items = list.GetItems(query);
&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPListItem item &lt;span class="kwrd"&gt;in&lt;/span&gt; items)
{
    System.Console.WriteLine(&lt;span class="str"&gt;&amp;quot;{0}--{1}&amp;quot;&lt;/span&gt;, item[&lt;span class="str"&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;], item[&lt;span class="str"&gt;&amp;quot;ProductProductName&amp;quot;&lt;/span&gt;]);
}&lt;/pre&gt;
    &lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;strong&gt;Code Snippet 3: Using generated CAML in SPQuery&lt;/strong&gt; 

    &lt;br /&gt;

    &lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Integrating the Test Code in your Visual Studio Soltuion&lt;/h4&gt;

&lt;p&gt;You may need to generate the CAML from time to time in your development life cycle. My personal preference is to keep a devtest project in the Visual Studio solution to do work like this CAML generation. I keep a dev-test project (used for RnD like task), mainly console app, in the solution. So you can keep the dev-test project in your solution and in that project you can write the Linq to SharePoint query and generate the CAML. Since the project will always be in your Visual Studio solution, if you need to get the CAML anytime you can just write the Linq query in the dev-test project and run the project to get the CAML. 
  &lt;br /&gt;&lt;/p&gt;

&lt;h4&gt;
  &lt;br /&gt;

  &lt;br /&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;So here’s the summary on how to generate CAML query using the method described in this post:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Install Visual Studio extension - CKS for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/ee876627-962c-4c35-a4a6-a4d89bfb61dc" target="_blank"&gt;SharePoint Server&lt;/a&gt; or for &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/a346880f-2d29-47a6-84a2-f2d568dd6997" target="_blank"&gt;SharePoint Foundation&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;Generate entity classes from SharePoint site using the CKS feature &lt;/li&gt;

  &lt;li&gt;Write Linq to SharePoint query and log the CAML in a file/Console &lt;/li&gt;

  &lt;li&gt;Use the CAML in SPQuery &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Though you can use Linq to SharePoint instead of CAML, but sometimes CAML is needed for raw query and this method will help you find out the CAML. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6704070518787337338?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6704070518787337338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/u2u-caml-query-builder-for-sharepoint.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6704070518787337338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6704070518787337338'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/u2u-caml-query-builder-for-sharepoint.html' title='U2U CAML Query Builder for SharePoint 2010?'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_o7Td6KCGNTA/TTalS6hha8I/AAAAAAAAAnE/M-uqIJ6y43U/s72-c/image_thumb1.png?imgmax=800' height='72' width='72'/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8768350178455779950</id><published>2011-01-13T10:09:00.000+01:00</published><updated>2011-01-13T13:42:15.791+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Configure Form Based Authentication (FBA)</title><content type='html'>&lt;p&gt;I had worked with form based authentication in SharePoint 2007. However, in SharePoint 2010, there’s few changes in the way form based authentication works. In my another post “&lt;a href="http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-form-based-authentication.html" target="_blank"&gt;Form-Based Authentication with ADAM&lt;/a&gt;”, I had described how to implement ADAM form based authentication in SharePoint 2007. Today I’ll show you how you can implement Form Based authentication using Active Directory Lightweight Directory Service. From windows server 2008, ADAM is replaced by Active Directory Lightweight Directory Service and both are LDAP based.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;FBA works for only for Claims based authentication sites&lt;/h4&gt;  &lt;p&gt;In SharePoint 2010 to use FBA, you need to create a web application with Claims based authentication as shown below. Form based authentication will not work for web application created with classical authentication.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TS7Ba6UJUUI/AAAAAAAAAmA/nt1sVQhqE20/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BcGve6vI/AAAAAAAAAmE/CLGgsqHPQVM/image_thumb11.png?imgmax=800" width="595" height="216" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Create web application in claims based authentication&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If you don’t create the web application with Claims Based Authentication then you’ll find the Forms Authentication type disabled in Authentication Provider settings window as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7Bc0wzQiI/AAAAAAAAAmI/Eow6U0W4k_8/s1600-h/image7.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TS7BeVFzdYI/AAAAAAAAAmM/x-wWeT8DcR8/image_thumb3.png?imgmax=800" width="610" height="185" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Forms authentication is disabled for web application created with “Classic Mode Authentication”&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 1: Create a web application with Claims Based Authentication&lt;/h4&gt;  &lt;p&gt;Since form based authentication doesn’t work with “Classical Mode Authentication”, you can’t configure form based authentication with web application created with “classic mode authentication”. So to configure Form based authentication you need to have an web application created with Claims based authentication. (&lt;font color="#ff0000"&gt;If you want to use windows authentication now and have plan to use forms based authentication later, then the best will be to create the web application with Claims based authentication&lt;/font&gt;). FYI,&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Creating a Claims based authentication will allow you to use both windows and form authentication. &lt;/li&gt;    &lt;li&gt;Creating a site with classic authentication mode will not allow you to configure the site to use form authentication easily. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt; In this step we’ll &lt;font style="background-color: #ffff00"&gt;create an web application using Claims Based Authentication &lt;strong&gt;but use windows authentication&lt;/strong&gt;&lt;/font&gt; as shown below. Later we’ll configure the site to use form authentication.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BfRkxKJI/AAAAAAAAAmQ/MiwLpqRkLhU/s1600-h/image41%5B1%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TS7BgYdXvJI/AAAAAAAAAmU/sdt49fQz8zk/image_thumb11%5B1%5D.png?imgmax=800" width="424" height="402" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Create Claims based authentication web application with only windows authentication enabled&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 2: Add membership provider entries in web.config files&lt;/h4&gt;  &lt;p&gt;In this example I’m considering you have the member provider configured already. I’ve been used “Active Directory Lightweight Directory Service” to test this form authentication. You need to modify three different web.config files (your web application, central admin and STS config file). Modifications to the three files are adding two entries (providers, connectionstring) to web.config file which are described below for three different places:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Web Application’s web.config:&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;You need to put the following entries in the web.config file of your web application under Configuration node:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;connectionStrings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyProviderConnectionString&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;connectionString&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;LDAP://myserver/O=a,OU=b,C=c&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;connectionStrings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Code Snippet 1: Connection String to LDAP&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Then find the &amp;lt;membership&amp;gt; node under &amp;lt;system.web&amp;gt; and add an entry for your provider (There should be an entry with name i, added by SharePoint already). As shown below I’ve added a provider “MyProvider” in the providers list. The provider with name “i&amp;quot; was already in the web.config file which is added by SharePoint when you create an web application with claims based authentication.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;membership&lt;/span&gt; &lt;span class="attr"&gt;defaultProvider&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;i&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;providers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;i&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyProvider&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Web.Security.ActiveDirectoryMembershipProvider,&lt;br /&gt;System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;connectionStringName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyProviderConnectionString&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;connectionUsername&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CN=aa,CN=Admins,O=a,OU=b,C=c&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;connectionPassword&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;***&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;enableSearchMethods&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; 
         &lt;span class="attr"&gt;connectionProtection&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;None&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;providers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;membership&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Code Snippet 2: My custom provider (MyProvider) added alongside the default SharePoint provider (i).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;SharePoint by default add the provider with name ‘i’. I’ve defined my provider with name MyProvider and the provider is using MyProviderConnectionString. so your web.config file will look like as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TS7BiEV1V4I/AAAAAAAAAmY/FDOXCpySavg/s1600-h/image%5B8%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TS7Bj7bQyrI/AAAAAAAAAmc/FjU369YMcSA/image_thumb%5B3%5D.png?imgmax=800" width="707" height="372" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 4: ConnectionString and Provider defined in web.config.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Security Token Service’s web.config file&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need to add the same entries for two other web.config files. One is central admin web.config file. Another one is Security Token Service (STS). You can find the STS web config file as shown below. The default location is “&lt;strong&gt;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken\Web.config&lt;/strong&gt;”.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BkwqrB_I/AAAAAAAAAmg/qvZw2fJuHJg/s1600-h/image8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TS7BmFYkTOI/AAAAAAAAAmk/CPeql0CryDc/image_thumb31.png?imgmax=800" width="615" height="471" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 5: Security Token Service (STS) web.cofig from IIS (Content View)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;After opening the config file, add the two entries as shown in code snippet 1 and code snippet 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Central Admin’s web.config file&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally you need to open the web.config file of central administration and add the two entries shown in code snippet 1 and 2.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Step 3: Change the web application’s security settings to use Form Authentication&lt;/h4&gt;

&lt;p&gt;So in Step 2, you have added the provider information (connection string, provider name, username etc) in three different web.config files. Now you need to tell the web application to use Form based authentication by connecting through your provider defined in web.config file. To do so follow the steps below:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Login to central administration site and click “Application Management” from left side navigation. &lt;/li&gt;

  &lt;li&gt;Select your web application from web application list and click “Authentication Providers” from ribbon as shown below: 
    &lt;blockquote&gt;
      &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TS7Bm7_2lAI/AAAAAAAAAmo/CDDje51byZk/s1600-h/image%5B4%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BojloePI/AAAAAAAAAms/2Kt-JrfXwrk/image_thumb%5B1%5D.png?imgmax=800" width="588" height="360" /&gt;&lt;/a&gt;&lt;/p&gt;

      &lt;p&gt;&lt;strong&gt;Figure 6: Configure Authentication Provider from Central Administration&lt;/strong&gt;&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;

  &lt;li&gt;From the “Authentication providers” dialog click on the zone (Default, internet etc) you want to configure the form authentication and then you will be redirected to “Edit Authentication” page. &lt;/li&gt;

  &lt;li&gt;In the Edit Authentication page, Put your provider name as shown below. You can enable both form and windows authentication if you want. As shown in the read in the image below, if you don’t configure windows authentication in any zone of the web application then crawling will be disabled. If you want you can enable anonymous login from this “Edit Authentication” page. &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TS7BpmgmC7I/AAAAAAAAAmw/ACFqiOHgc58/s1600-h/image%5B12%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TS7BqpzfqzI/AAAAAAAAAm0/rHjTHfsgu_k/image_thumb%5B5%5D.png?imgmax=800" width="517" height="475" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;Figure 7: Enable Form authetication&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Step 4: Assign/change site collection administrators for the site collections&lt;/h4&gt;

&lt;p&gt;As soon you change the authentication type to form, you will have to assign an user (from your provider defined in web config file) to the site collection administrators. &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Click Application Management ==&amp;gt; Change Site Collection Administrators &lt;/li&gt;

  &lt;li&gt;Then add the users from your providers in site collection administrator's group as shown below: &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TS7BsKqlD1I/AAAAAAAAAm4/DCjjPEJ35xY/s1600-h/image%5B16%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BtJ_GymI/AAAAAAAAAm8/GzFeuWWtcSc/image_thumb%5B7%5D.png?imgmax=800" width="764" height="317" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;Figure 8: Add/Edit Site collection administrators&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you enable both windows and form authentication then it’ll be better to use one site collection administrator from windows and another from your form based authentication’s provider.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;You are done!&lt;/h4&gt;

&lt;p&gt;And if you have followed the steps, you are done. If you try to access the site, you will be prompted for form login page. However, if you enabled both form and windows authentication then you will prompted for authentication&amp;#160; type first and based on the authentication type either you will be prompted for form or windows authentication.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;For Your Information&lt;/h4&gt;

&lt;p&gt;Few points to notice here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Form based authentication only works for web application created with Claims Based Authentication mode. &lt;/li&gt;

  &lt;li&gt;You need to modify three web.config files (your web application, central web app and Security Token Service) to add your provider settings. &lt;/li&gt;

  &lt;li&gt;Recommendation is to create an web application with Claims based Authentication mode but using windows authentication. Once you modify those three web.config files, switch the web app to form based. &lt;/li&gt;

  &lt;li&gt;You can enable both windows and form authentication in a web application. In that case try to add one site collection administrator from form authentication provider and another from windows. &lt;/li&gt;

  &lt;li&gt;If you want the site data to be crawled, then you need to make sure at lease one zone in the web application uses windows authentication. &lt;/li&gt;
&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8768350178455779950?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8768350178455779950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/sharepoint-2010-form-based.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8768350178455779950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8768350178455779950'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/sharepoint-2010-form-based.html' title='SharePoint 2010: Configure Form Based Authentication (FBA)'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TS7BcGve6vI/AAAAAAAAAmE/CLGgsqHPQVM/s72-c/image_thumb11.png?imgmax=800' height='72' width='72'/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5839418095017397054</id><published>2011-01-05T12:10:00.000+01:00</published><updated>2011-01-05T12:13:33.823+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Branding'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Add favicon icon to site</title><content type='html'>&lt;p&gt;In SharePoint if you need to add favicon, you can do so easily by using SharePoint Out-of-box control SPShortcutIcon. The following code snippet shows how you can set the favicon:asdf&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SharePoint:SPShortcutIcon&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;=”&lt;span style="color: #ff0000"&gt;server&lt;/span&gt;” &lt;span style="color: #ff0000"&gt;IconUrl&lt;/span&gt;=”&lt;span style="color: #ff0000"&gt;YourIconUrl&lt;/span&gt;”&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;You are done…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5839418095017397054?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5839418095017397054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/sharepoint-2010-add-favicon-icon-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5839418095017397054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5839418095017397054'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/sharepoint-2010-add-favicon-icon-to.html' title='SharePoint 2010: Add favicon icon to site'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-854239505437402705</id><published>2011-01-03T09:11:00.000+01:00</published><updated>2011-01-03T09:14:12.298+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='miscellaneous'/><title type='text'>Awarded Microsoft MVP</title><content type='html'>&lt;p&gt;The very good news for me that I’ve come to know on 1st January is that I’ve been awarded Microsoft MVP for &lt;strong&gt;SharePoint Server: Development&lt;/strong&gt;. My blog has got much popularity in last few months. On November there were almost 10000 visitors and on December around 9000 visitors visited my blog. Thanks all the visitors of the site for their comments and feedback. I’ll continue my efforts to help SharePoint community with blogs, MSDN forms etc.&lt;/p&gt;  &lt;p&gt;Thanks again to all visitors who commented and provided feedback in my blog.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-854239505437402705?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/854239505437402705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/awarded-microsoft-mvp.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/854239505437402705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/854239505437402705'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2011/01/awarded-microsoft-mvp.html' title='Awarded Microsoft MVP'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-4803300380046644139</id><published>2010-12-31T16:36:00.000+01:00</published><updated>2010-12-31T16:39:02.609+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Metadata Magement (EMM)'/><category scheme='http://www.blogger.com/atom/ns#' term='Taxonomy'/><title type='text'>SharePoint 2010: Taxonomy Event Receiver?</title><content type='html'>&lt;p&gt;One of the power of SharePoint is extensibility. You can hook your custom code in different places in different time with Event Receiver. Taxonomy is new and powerful feature added in SharePoint 2010. Unfortunately, the taxonomy missing event receiver feature. If you want to do something when taxonomy added, deleted or updated, you are unlucky that SharePoint 2010 doesn’t provide event receiver in SharePoint 2010 for taxonomy. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Why taxonomy event receiver needed?&lt;/h4&gt;  &lt;p&gt;With taxonomy support, SharePoint is a good place to manage taxonomy. However, if I need this taxonomy to use in another application (like another asp.net application) then with the event receiver I could sync my asp.net application with SharePoint taxonomy. Also when a taxonomy is deleted I would like to run my own code to allow or disallow the deletion. So taxonomy event receiver would be very handy if it would be available.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;How taxonomy managed in SharePoint?&lt;/h4&gt;  &lt;p&gt;Let’s discuss a bit about how taxonomy managed in SharePoint. Taxonomy is managed by central administration (with managed metadata service). So when you add/delete/update taxonomy, the taxonomies are managed in central administration site. However, for faster retrieval of taxonomies in individual web, a hidden list of taxonomies maintained in each site collection. So in each site collection, there’s a hidden list &lt;strong&gt;TaxonomyHiddenList &lt;/strong&gt;that keeps the copy of taxonomies from central administration site. And in every hour a timer job “&lt;strong&gt;Taxonomy Update Scheduler&lt;/strong&gt;” is run to sync the taxonomies between central admin and site collection. However, the hidden list in site collection doesn’t contain all taxonomies from central admin rather taxonomies that are used in the webs of the site collection. So the hidden taxonomy list have only keywords and taxonomies used in the webs of the site collection. You can get the contents of the hidden list by browsing “&lt;a title="http://mysitecollection/Lists/TaxonomyHiddenList" href="http://mysitecollection/Lists/TaxonomyHiddenList"&gt;http://mysitecollection/Lists/TaxonomyHiddenList&lt;/a&gt;” where mysitecollection is your site collection url. Few things to notice for the hidden list:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In case of edit mode, the taxonomy is read from central administration and as user save the list item, the taxonomy/keywords is saved from hidden list. &lt;/li&gt;    &lt;li&gt;In case of viewing an item, it’s for sure that the taxonomy/keyword is in hidden list (it was put in hidden list during edit mode). So the taxonomy/keyword is shown from hidden list. &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Event Receiver for Taxonomy Hidden List&lt;/h4&gt;  &lt;p&gt;Now we know the taxonomies are kept in a hidden list at site collection level. And in every hour,&amp;#160; the hidden list is synchronized with central administration site. So if we add event receiver for the hidden taxonomy list,then in every hour our event receiver will be fired while the hidden list will be synchronized. So adding an event receiver for hidden taxonomy list will solve the problem apparently. But there’s still problem. Not all taxonomies are added to the hidden list from central administration. Only the taxonomies added to subsites of site collection, are added to the hidden list. Now the problem of event receiver for taxonomies can be divided into two categories:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h5&gt;Need event receiver only for taxonomies used in subsite of site collection: &lt;font style="font-weight: normal"&gt;If you need the event receiver only for taxonomies used in subsites of site collection, then having the event receiver for hidden taxonomies will do. However, you’ll have to wait for one hour to fire the event receiver. &lt;/font&gt;&lt;/h5&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;h5&gt;Need event receiver for all taxonomies: &lt;font style="font-weight: normal"&gt;If you need your event receiver to be fired for every taxonomy (added/edited/deleted) manipulation, then tapping the hidden taxonomy list will not work as not all taxonomies will be added from central admin to hidden taxonomy list. So what might be the solution for this? One solution is to create a custom timer job of your own and in that timer job, use all taxonomies in a test list. Since all taxonomies are used in your site, so all taxonomies will be synchronized with the site collection and your event receiver will be fired for all taxonomies.&lt;/font&gt;&lt;/h5&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h5&gt;&amp;#160;&lt;/h5&gt;  &lt;h4&gt;Solution (Re-explained)&lt;/h4&gt;  &lt;p&gt;so if only care for taxonomies used in the site collection then adding an event receiver for hidden list will work. In every hour the hidden taxonomy lists will be synchronized and your event receiver for that hidden list will be fired.&lt;/p&gt;  &lt;p&gt;However, if you need to care all taxonomies (not just taxonomies used in the site collection), then you need to follow the steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a test list with one metadata field.&lt;/li&gt;    &lt;li&gt;Create a timer job to add all metadata from central admin to the list’s metadata field. The purpose of this job is make sure all taxonomies from central admin are used in site collection.&lt;/li&gt;    &lt;li&gt;Now add the event receiver for hidden list and you are done. &lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-4803300380046644139?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/4803300380046644139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-taxonomy-event-receiver.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4803300380046644139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4803300380046644139'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-taxonomy-event-receiver.html' title='SharePoint 2010: Taxonomy Event Receiver?'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5973449849286025743</id><published>2010-12-25T16:17:00.000+01:00</published><updated>2010-12-25T16:20:26.070+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Linking SharePoint User to Active Directory User</title><content type='html'>&lt;p&gt;While we are using SharePoint Foundation, Sometimes we need to get the active directory user details based on current logged in user. If you are using SharePoint Server then this is not a big deal as you can get the user details through user profile. However, if you are using SharePoint Foundation then there’s no shortcut way to getting user details. However, one of my client is using SharePoint Foundation and wanted to get the user details from active directory (say user’s First Name). Here’s how I’ve achieved this:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 1: Created a timer job to import user details from Active Directory&lt;/h4&gt;  &lt;p&gt;I have created a custom list to store imported data from Active Directory into SharePoint. The list looks like below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TRYLOUNAE1I/AAAAAAAAAlk/kjtPKg13IQo/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TRYLRlv47YI/AAAAAAAAAlo/FQ6RTNJX5kI/image_thumb%5B7%5D.png?imgmax=800" width="818" height="140" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: SharePoint List to keep Active Directory User Details&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As shown in the figure 1, the SID is the key to map a SharePoint user to Active Directory User. The following code snippet shows the code to import data&lt;/p&gt;  &lt;p&gt;First I created DTO class to represent LDAP User:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; LdapUser
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; ID { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsActive { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FirstName { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; LastName { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Email { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SId { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; DisplayName { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; UserName { get; set; }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 2: An DTO to keep Active directory and/or SharePoint list data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The following code is to get the Active Directory data into LdapUser DTO:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; IList&amp;lt;LdapUser&amp;gt; GetUsersFromActiveDirectory(&lt;span class="kwrd"&gt;string&lt;/span&gt; connectionString, &lt;span class="kwrd"&gt;string&lt;/span&gt; userName, &lt;span class="kwrd"&gt;string&lt;/span&gt; password)
{
    var users = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;LdapUser&amp;gt;();

    &lt;span class="kwrd"&gt;using&lt;/span&gt; (var directoryEntry = &lt;span class="kwrd"&gt;new&lt;/span&gt; DirectoryEntry(connectionString, userName, password, AuthenticationTypes.None))
    {
        var directorySearcher = &lt;span class="kwrd"&gt;new&lt;/span&gt; DirectorySearcher(directoryEntry);
        directorySearcher.Filter =
            &lt;span class="str"&gt;&amp;quot;(&amp;amp;(objectClass=user)(objectClass=person)(objectClass=organizationalPerson)(!objectClass=computer))&amp;quot;&lt;/span&gt;;
        var propertiesToLoad = &lt;span class="kwrd"&gt;new&lt;/span&gt;[] 
        { 
            &lt;span class="str"&gt;&amp;quot;SAMAccountName&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;displayName&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;givenName&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;sn&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;mail&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;userAccountControl&amp;quot;&lt;/span&gt;, 
            &lt;span class="str"&gt;&amp;quot;objectSid&amp;quot;&lt;/span&gt; 
        };
        directorySearcher.PropertiesToLoad.AddRange(propertiesToLoad);

        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SearchResult searchEntry &lt;span class="kwrd"&gt;in&lt;/span&gt; directorySearcher.FindAll())
        {
            var userEntry = searchEntry.GetDirectoryEntry();
            var ldapUser = &lt;span class="kwrd"&gt;new&lt;/span&gt; LdapUser();
            ldapUser.DisplayName = NullHandler.GetString(userEntry.Properties[&lt;span class="str"&gt;&amp;quot;displayName&amp;quot;&lt;/span&gt;].Value);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;.IsNullOrEmpty(ldapUser.DisplayName))
                &lt;span class="kwrd"&gt;continue&lt;/span&gt;;
            ldapUser.Email = NullHandler.GetString(userEntry.Properties[&lt;span class="str"&gt;&amp;quot;mail&amp;quot;&lt;/span&gt;].Value);
            ldapUser.FirstName = NullHandler.GetString(userEntry.Properties[&lt;span class="str"&gt;&amp;quot;givenName&amp;quot;&lt;/span&gt;].Value);
            ldapUser.LastName = NullHandler.GetString(userEntry.Properties[&lt;span class="str"&gt;&amp;quot;sn&amp;quot;&lt;/span&gt;].Value);
            ldapUser.UserName = NullHandler.GetString(userEntry.Properties[&lt;span class="str"&gt;&amp;quot;SAMAccountName&amp;quot;&lt;/span&gt;].Value);
            var userAccountControl = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)userEntry.Properties[&lt;span class="str"&gt;&amp;quot;userAccountControl&amp;quot;&lt;/span&gt;].Value;
            ldapUser.IsActive = (userAccountControl &amp;amp; UF_ACCOUNTDISABLE) != UF_ACCOUNTDISABLE;
            var sid = &lt;span class="kwrd"&gt;new&lt;/span&gt; SecurityIdentifier((&lt;span class="kwrd"&gt;byte&lt;/span&gt;[])userEntry.Properties[&lt;span class="str"&gt;&amp;quot;objectSid&amp;quot;&lt;/span&gt;][0], 0).Value;
            ldapUser.SId = sid;
            users.Add(ldapUser);
        }
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; users;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 2: A method to get Active Directory User data in DTO format&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The above method GetUsersFromActiveDirectory return the Ldap dto from Active Directory. Then you need to save the Ldap dto into SharePoint. The following code shown the method that will save the Ldap dto in SharePoint list:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SaveActiveDirectoryUsersToSharePointList(SPWeb currentWeb, IList&amp;lt;LdapUser&amp;gt; ldapUsers)
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; query = &lt;span class="str"&gt;@&amp;quot;&amp;lt;Where&amp;gt;&amp;lt;Eq&amp;gt;&amp;lt;FieldRef Name='SID'/&amp;gt;&amp;lt;Value Type='Text'&amp;gt;{0}&amp;lt;/Value&amp;gt;&amp;lt;/Eq&amp;gt;&amp;lt;/Where&amp;gt;&amp;quot;&lt;/span&gt;;
    var ldapUserList = currentWeb.Lists[&lt;span class="str"&gt;&amp;quot;LDAPUsers&amp;quot;&lt;/span&gt;];
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var ldapUser &lt;span class="kwrd"&gt;in&lt;/span&gt; ldapUsers)
    {
        SPQuery spQuery = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPQuery();
        spQuery.Query =  &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(query, ldapUser.SId);
        var items = ldapUserList.GetItems(spQuery);

        SPListItem listItem;

        &lt;span class="rem"&gt;//if the user exists with the same Sid then update &lt;/span&gt;
        &lt;span class="rem"&gt;//either create a new list item.&lt;/span&gt;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (items.Count == 1)
        {
            listItem = items[0];
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            listItem = ldapUserList.AddItem();
        }
        listItem[Constants.Lists.LdapUsersList.Email] = ldapUser.Email;
        listItem[Constants.Lists.LdapUsersList.FirstName] = ldapUser.FirstName;
        listItem[Constants.Lists.LdapUsersList.LastName] = ldapUser.LastName;
        listItem[Constants.Lists.LdapUsersList.DisplayName] = ldapUser.DisplayName;
        listItem[Constants.Lists.LdapUsersList.IsActive] = ldapUser.IsActive;
        listItem[Constants.Lists.LdapUsersList.PID] = ldapUser.SId;
        listItem[Constants.Lists.LdapUsersList.UserName] = ldapUser.UserName;
        listItem.Update();
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 3: A method to save DTO (LdapUser) in SharePoint list.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In the above method SaveActiveDirectoryUsersToSharePointList, if a listitem with the same SId as in the LdapUsers list, then the list item is updated or a new one is added. So SId is key to synchronize list item and Active Directory item.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;After User data is imported from Active Directory to SharePoint, the SharePoint list has use details. As shown in the image below, the user doceditor properties in Active Directory is shown on the left side whereas the imported SharePoint list in right side.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TRYLYhavo9I/AAAAAAAAAls/BZ3DrIfcJiU/s1600-h/image%5B23%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TRYLnY-RKyI/AAAAAAAAAlw/pkr_qu7iiVA/image_thumb%5B15%5D.png?imgmax=800" width="825" height="278" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 4: Active Directory User and SharePoint list item side-by-side&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Finally you can create a timer job to sync data from Active Directory to SharePoint list. However, I’m skipping this step for brevity.&lt;/p&gt;

&lt;h4&gt;Step 2: Retrieve SPUser’s details from SharePoint List where Active Directory data imported&lt;/h4&gt;

&lt;p&gt;As shown in the code below, you can get current SharePoint user’s SId by accessing SPUser’s Sid property. Once you have the sid you can query the list (LDAPUsers) where you imported the user data from Active Directory.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var ldapList = currentWeb.Lists[&lt;span class="str"&gt;&amp;quot;LDAPUsers&amp;quot;&lt;/span&gt;];
var currentUserSid = currentWeb.CurrentUser.Sid;
var query = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPQuery();
query.Query = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;@&amp;quot;&amp;lt;Where&amp;gt;
                    &amp;lt;Eq&amp;gt;
                        &amp;lt;FieldRef Name='PID'  /&amp;gt;
                        &amp;lt;Value Type='Text'&amp;gt;{0}&amp;lt;/Value&amp;gt;
                    &amp;lt;/Eq&amp;gt;
                &amp;lt;/Where&amp;gt;&amp;quot;&lt;/span&gt;, sid);
var items = ldapList.GetItems(query);
&lt;span class="kwrd"&gt;if&lt;/span&gt; (items.Count == 1)
{
    var ldapUserListItem = items[0];
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;So the Active directory sid is mapped to current SPUser’s Sid. So you can access the Active Directory user’s Sid using code shown below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var sid = &lt;span class="kwrd"&gt;new&lt;/span&gt; SecurityIdentifier((&lt;span class="kwrd"&gt;byte&lt;/span&gt;[])userEntry.Properties[&lt;span class="str"&gt;&amp;quot;objectSid&amp;quot;&lt;/span&gt;][0], 0).Value;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Then you can get the SharePoint User’s Sid by using the code snippet below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;SPContext.Current.Web.CurrentUser.Sid&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Once you have the mapping, you can import any data from Active Directory to SharePoint list, sync the data with timer job and get the data of current logged in user from SharePoint list.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5973449849286025743?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5973449849286025743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-linking-sharepoint-user.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5973449849286025743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5973449849286025743'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-linking-sharepoint-user.html' title='SharePoint 2010: Linking SharePoint User to Active Directory User'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TRYLRlv47YI/AAAAAAAAAlo/FQ6RTNJX5kI/s72-c/image_thumb%5B7%5D.png?imgmax=800' height='72' width='72'/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-475073340459578984</id><published>2010-12-14T10:25:00.001+01:00</published><updated>2010-12-14T10:25:53.332+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Enterprise Metadata Magement (EMM)'/><title type='text'>SharePoint 2010: Create Taxonomy Error “Term set update failed because of save conflict.”</title><content type='html'>&lt;p&gt;I was trying to answer a user’s problem in MSDN forum. He was trying to add a term in term store. Using the term adding code (that I have taken from the post) I was getting the error “Term set update failed because of save conflict.” while I was calling the CommitAll method. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Problematic Code&lt;/h4&gt;  &lt;p&gt;My code is as shown below:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddTerminTermStoreManagement(&lt;span class="kwrd"&gt;string&lt;/span&gt; siteUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; termSetName, &lt;span class="kwrd"&gt;string&lt;/span&gt; Term)
{
    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        &lt;span class="kwrd"&gt;using&lt;/span&gt; (var siteTerm = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPSite(siteUrl))
        {
            var sessionTerm = &lt;span class="kwrd"&gt;new&lt;/span&gt; TaxonomySession(siteTerm);
            var termStoreTerm = sessionTerm.DefaultSiteCollectionTermStore;
                    
            var collection = termStoreTerm.GetTermSets(termSetName, 1033);
            var termSet = collection.FirstOrDefault();

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!termSet.IsOpenForTermCreation)
            {
                &lt;font style="background-color: #ffff00"&gt;termSet.IsOpenForTermCreation = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/font&gt;
            }

            termSet.CreateTerm(Term, sessionTerm.TermStores[0].DefaultLanguage);
            termStoreTerm.CommitAll();
        }

    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt;
    {

    }

}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;After investigating the code I had found the problem was in the line as shown in the above code snippet with yellow marker (termSet.IsOpen..).&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Solution&lt;/h4&gt;

&lt;p&gt; I have fixed the error by modifying the code as shown below. I had just called the CommitAll just after changing the value of IsOpenForTermCreation as shown below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddTerminTermStoreManagement(&lt;span class="kwrd"&gt;string&lt;/span&gt; siteUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; termSetName, &lt;span class="kwrd"&gt;string&lt;/span&gt; Term)
{
    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        &lt;span class="kwrd"&gt;using&lt;/span&gt; (var siteTerm = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPSite(siteUrl))
        {
            var sessionTerm = &lt;span class="kwrd"&gt;new&lt;/span&gt; TaxonomySession(siteTerm);
            var termStoreTerm = sessionTerm.DefaultSiteCollectionTermStore;
                    
            var collection = termStoreTerm.GetTermSets(termSetName, 1033);
            var termSet = collection.FirstOrDefault();

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!termSet.IsOpenForTermCreation)
            {
                termSet.IsOpenForTermCreation = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
               &lt;font color="#ff0000"&gt; &lt;font style="background-color: #ffff00"&gt;termStoreTerm.CommitAll();&lt;/font&gt;&lt;/font&gt;
            }

            termSet.CreateTerm(Term, sessionTerm.TermStores[0].DefaultLanguage);
            termStoreTerm.CommitAll();
        }

    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt;
    {

    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;So the problem was that when I changed the value of IsOpenForTermCreation, there was a commit pending. So without committing, I created a new term and tried to committed. So the save conflict error was thrown. &lt;font color="#ff0000"&gt;If you get the same error in different scenario then u can check if u have any pending commit that u have not committed.&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-475073340459578984?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/475073340459578984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-create-taxonomy-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/475073340459578984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/475073340459578984'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-create-taxonomy-error.html' title='SharePoint 2010: Create Taxonomy Error “Term set update failed because of save conflict.”'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-7123144405787569453</id><published>2010-12-13T17:00:00.001+01:00</published><updated>2010-12-23T13:26:53.549+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Bug and Error'/><title type='text'>SharePoint 2010 Error: Accessing lookup field values using Elevated web generates exception “Value does not fall within the expected range” when the lookup fields exceeds the lookup threshould</title><content type='html'>&lt;p&gt;I have a list which has 9 look columns. By default SharePoint doesn’t allow that more than 8 lookup columns (However you can modify the value). When I tried to access the list from SharePoint list view, I could access the list without any problem. I was even accessing the list from webpart code and it was working fine.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;All of sudden I had found some piece of my code is not working. While I was trying to access the 9th lookup column value of the SharePoint List from webpart&amp;#160; code I had got the error “&lt;font color="#ff0000"&gt;Value does not fall within the expected range&lt;/font&gt;”. After investigating the problem I had found the 9th field doesn’t exist in the list. After spending some time on the issue, the final summary is:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;So, If your list’s lookup columns exceeds the Lookup column threshold and if you try to access the list lookup field value from code using elevated web, then you will get the error “Value does not fall within the expected range”. And interestingly the exception will be thrown for not all lookup fields rather the ‘n+1’ lookup fields whereas the n is the lookup field threshold value.&amp;quot;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;Problem At a glance&lt;/h4&gt;  &lt;p&gt;So here is how you can reproduce the issue: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;You have set the list view lookup threshold to N. &lt;/li&gt;    &lt;li&gt;Then you have a list MyList with more than N lookup fields. &lt;/li&gt;    &lt;li&gt;If you try to access the list from SharePoint UI, you can access the list. &lt;/li&gt;    &lt;li&gt;Even if you try to access the list from code with SharePoint object model using SPContext.Current.Web you can access all lookup field values. &lt;/li&gt;    &lt;li&gt;However, If you try to access the lookup field values using Elevated web (code under SPSecurity.RunWithElevated) you will get error for N+1 lookup fields. &lt;/li&gt; &lt;/ol&gt;  &lt;h4&gt;Sample Code to regenerate the issue&lt;/h4&gt;  &lt;p&gt;The following code block I used to test the issue. To run the test I had set the lookup column limit to two from central admin. So the code can read first two field’s lookup value but get exception to read the third.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;var webId = SPContext.Current.Web.ID;
var siteId = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(
() =&amp;gt;
{
    &lt;span class="kwrd"&gt;using&lt;/span&gt; (SPSite site = &lt;span class="kwrd"&gt;new&lt;/span&gt; SPSite(siteId))
    {
        &lt;span class="kwrd"&gt;using&lt;/span&gt; (SPWeb web = site.OpenWeb(webId))
        {
            var fields = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[] {&lt;span class="str"&gt;&amp;quot;LooupField1&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;LookupField2&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;LookupField3&amp;quot;&lt;/span&gt;};
            var lookupTestList = web.Lists[&lt;span class="str"&gt;&amp;quot;LookupTestList&amp;quot;&lt;/span&gt;];
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (SPListItem spListItem &lt;span class="kwrd"&gt;in&lt;/span&gt; lookupTestList.Items)
            {
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var f &lt;span class="kwrd"&gt;in&lt;/span&gt; fields)
                {
                    &lt;span class="kwrd"&gt;try&lt;/span&gt;
                    {
                        &lt;span class="rem"&gt;//get excception here for reading lookup col 3&lt;/span&gt;
                        var value1 = spListItem[f];
                    }
                    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception exception)
                    {
                        Response.Write(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Error in reading field: {0}. Error: {1}&amp;quot;&lt;/span&gt;, f, exception.Message));
                    }
                }
            }
        }
    }
});&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The points to notice to regenerate the issue:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The exception is not thrown if I try the same code shown above in console application. However, the exception is thrown when I tried to run it webpart.&lt;/li&gt;

  &lt;li&gt;The exception is shown when I try to get the items by accessing List.Items. However the exception is not thrown when I get the item using any other means (like list.GetItemById etc)&lt;/li&gt;
&lt;/ul&gt;





&lt;p&gt;&lt;font color="#ff0000"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-7123144405787569453?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/7123144405787569453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-error-list-view-lookup.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7123144405787569453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7123144405787569453'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2010-error-list-view-lookup.html' title='SharePoint 2010 Error: Accessing lookup field values using Elevated web generates exception “Value does not fall within the expected range” when the lookup fields exceeds the lookup threshould'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6595824495074726302</id><published>2010-12-02T13:25:00.000+01:00</published><updated>2010-12-02T13:27:06.267+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2007 and Visual Studio 2010: Resolution of “w3wp process does not attach” problem</title><content type='html'>&lt;p&gt;Recently we have moved to Visual Studio 2010 for our SharePoint project. In Visual Studio 2008 we were using WSP builder to manage SharePoint deployment. After moving to Visual Studio 2010, we have used beta version of WSP 2010. We had converted our SharePoint projects successfully to VS 2010, we tested deployments and others are working great with VS 2010 and WSP 2010. However when we tried to start developing, we had found that w3wp process can’t be attached. We tried different approach, sometimes the attaching worked but only for the first time. If we detach the debugger and then try to attach again the debugger doesn’t work for the second time.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;After Googling I had found another person Patrick Lamber has solved the problem in &lt;a href="http://patricklamber.blogspot.com/2010/07/i-cant-attach-for-debugging-visual.html" target="_blank"&gt;his blog&lt;/a&gt;. I’m reposting it in details hoping this might be helpful for someone. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Click &lt;em&gt;Debug&lt;/em&gt; =&amp;gt; &lt;em&gt;Attach to Process&lt;/em&gt;. The “Attach to Process” dialog comes up. &lt;/li&gt;    &lt;li&gt;     &lt;div align="center"&gt;In the “Attach to Process” dialog, click &lt;em&gt;Select&lt;/em&gt; button, which will show “Select Code Type” dialog as shown below: &lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TPeQjsIxdiI/AAAAAAAAAlU/bYYGR-0755c/s1600-h/image%5B9%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TPeQlBW8AGI/AAAAAAAAAlY/IISdg1iyTE4/image_thumb%5B5%5D.png?imgmax=800" width="644" height="445" /&gt;&lt;/a&gt; &lt;strong&gt;Figure 1: Change Code Type dialog&lt;/strong&gt; &lt;/div&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;In the “Select Code Type” dialog, select “Debug these types of code” and then check option for “Managed (v2.0..) &lt;/li&gt;    &lt;li&gt;You are done. Now you can try attaching debugger. Hope it’ll work. &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TPeQmFEgd-I/AAAAAAAAAlc/m_FJrHDi24Y/wlEmoticon-smile%5B2%5D.png?imgmax=800" /&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6595824495074726302?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6595824495074726302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2007-and-visual-studio-2010.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6595824495074726302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6595824495074726302'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/12/sharepoint-2007-and-visual-studio-2010.html' title='SharePoint 2007 and Visual Studio 2010: Resolution of “w3wp process does not attach” problem'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_o7Td6KCGNTA/TPeQlBW8AGI/AAAAAAAAAlY/IISdg1iyTE4/s72-c/image_thumb%5B5%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8752561365771758156</id><published>2010-11-26T13:39:00.000+01:00</published><updated>2010-11-28T13:33:07.306+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Receiver'/><title type='text'>SharePoint: Diagnose “Error loading and running event receiver” problem</title><content type='html'>&lt;p&gt;We developer gain experience as we work more and spend more time on learning and applying. Mostly, we only care about the how expertise developers are, in implementing things. But I also emphasis on another dimension of experience: “How expertise developers are in fixing or diagnosing problem”. This diagnosing expertise can mainly be gained with more and more real life working experience. Maybe everyday or every week or every moth, you face a problem and find out the solution by debugging or writing logs or finding solution on the internet. That’s how a problem&amp;#160; is resolved but this may lead you to an experienced person in solving similar problems or at least helping you diagnosing similar problems.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Ok, I’m beating around the bush, let me come to the real problem that the post is all about. If you have come around the problem that your event receiver is not running and you found that in log file the error message is something like “Error loading and running event receiver…” then you need to find out what’s wrong with the receiver. As the error message says, the problem might be with loading the event receiver or running the event receiver. You need to find out first if the problem is in loading event receiver. If the problem is in loading event receiver the fix the problem first.&amp;#160; To find out the issue, you can use the following steps: &lt;/p&gt;  &lt;h4&gt;Step 1: Event Receiver Loading Problem?&lt;/h4&gt;  &lt;p&gt;You need to find out first if your event receiver is executing or being invoked. The simplest way might be to use logging. If you already have logging capability in your code, you can use the logging. But make sure logging doesn’t have any permission related problem. The easiest way to resolve the issue is to allow user ‘everyone’ to have full control in the file/folder where the log file will be saved. However, revert the permission once you are done with diagnosis.&lt;/p&gt;  &lt;p&gt;If your logging works from event receiver, then clearly, the problem is not loading receiver. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 2: Event Receiver Running Problem?&lt;/h4&gt;  &lt;p&gt;From step 1 if you find the problem is not loading problem then surely the problem is in running the event receiver. So put proper logs in the event receiver in tracking the problem.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8752561365771758156?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8752561365771758156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-diagnose-error-loading-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8752561365771758156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8752561365771758156'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-diagnose-error-loading-and.html' title='SharePoint: Diagnose “Error loading and running event receiver” problem'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3626429760719162583</id><published>2010-11-20T09:08:00.000+01:00</published><updated>2010-11-20T09:09:17.289+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Receiver'/><title type='text'>SharePoint: Event Receiver and Assembly Versions</title><content type='html'>&lt;p&gt;I had encountered an interesting problem with event receiver few days back. By default we are used to attach an event receiver class to a list by declaring the event receiver in an xml file as shown below:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Receivers&lt;/span&gt; &lt;span class="attr"&gt;ListTemplateId&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;101&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Receiver&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;MyEverReceiverOnAdd&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;ItemAdded&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SequenceNumber&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SequenceNumber&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Assembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;MyProject.MyEventReceiver, &lt;font style="background-color: #ffff00"&gt;Version=2.1.0.0&lt;/font&gt;, Culture=neutral, PublicKeyToken=&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Assembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Class&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;PermissionsEventHandler.PermissionsHandler&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Class&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Data&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Data&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Receiver&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Receivers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 1: Event Receiver for version 2.1.0.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the xml file above we need to specify the version of the assembly. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Let’s image a scenario:&lt;/p&gt;

&lt;p&gt;1. You have deployed your SharePoint solution (which has event receivers) while the assembly version is 2.1.0.0. So when you deployed the SharePoint solution, the list event receivers&amp;#160; in the SharePoint webs are registered with that 2.1.0.0 version of dll.&lt;/p&gt;

&lt;p&gt;2. After few months, another version of your product is ready and you have changed the dll version (as this is practice to change your dll version as the development goes on). Now your dll version is 2.2.0.0. So you have updated the event receiver’s definition in xml file to reflect the new dll version as shown below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Receivers&lt;/span&gt; &lt;span class="attr"&gt;ListTemplateId&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;101&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Receiver&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;MyEverReceiverOnAdd&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;ItemAdded&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;SequenceNumber&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;SequenceNumber&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Assembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;MyProject.MyEventReceiver, &lt;font style="background-color: #ffff00"&gt;Version=2.2.0.0&lt;/font&gt;, Culture=neutral, PublicKeyToken=&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Assembly&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Class&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;PermissionsEventHandler.PermissionsHandler&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Class&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Data&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Data&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Receiver&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Receivers&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 2:Event Receiver for version 2.2.0.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;3. Now if you deploy the latest version of dll in server, the old assembly will be removed from GAC.Now you can get two different behaviors:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;New site&lt;/strong&gt;: If you create a new site after version 2.2.0.0 is deployed, there’ll be no problem as the new site will register it’s event receiver with the updated xml (which is using 2.2.0.0.0 as shown in image 2). &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Old site&lt;/strong&gt;: &lt;font color="#ff0000"&gt;Here’s your are in trouble&lt;/font&gt;. You attached the event receiver after the version 2.1.0.0 is deployed. So the lists will look for that version of dll in GAC.&amp;#160; &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;&amp;#160;&lt;/h4&gt;

&lt;h4&gt;Solutions:&lt;/h4&gt;

&lt;p&gt;So how can you handle the situation? After googling and analyzing I have found three solutions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Fixed Version&lt;/strong&gt;: One solution might be to keep the event receiver classes in a project whose version will not be changed. So you’ll always refer to the an assembly with the same dll version. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Deactivate/Activate Old Features&lt;/strong&gt;: Another solution might be to uninstall/Deactive and then install/activate the event receiver features for all old sites. But this will add extra overhead in deployment. Additionally, if the number of webs are larger then it’s not viable solution. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;DotNet Publisher Policy&lt;/strong&gt;: .net publisher policy can be another option to redirect the reference of old assembly to new one. More information on publisher policy can be found in the links: &lt;a href="http://msdn.microsoft.com/en-us/library/dz32563a.aspx"&gt;http://msdn.microsoft.com/en-us/library/dz32563a.aspx&lt;/a&gt;, &lt;a href="http://support.microsoft.com/kb/891030"&gt;http://support.microsoft.com/kb/891030&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-3626429760719162583?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/3626429760719162583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-event-receiver-and-assembly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3626429760719162583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3626429760719162583'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-event-receiver-and-assembly.html' title='SharePoint: Event Receiver and Assembly Versions'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-7765752360571542419</id><published>2010-11-08T19:08:00.001+01:00</published><updated>2010-11-08T19:08:22.151+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Backup Restore'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010 Error: Cannot make a cache safe URL for "1031/styles/Themable/corev4.css", file not found. Please verify that the file exists under the layouts directory.</title><content type='html'>&lt;p&gt;I had to take backup from my client’s production site to make some analysis in my local server. So I took backup and restored the site in local server. Restored was successful. Then I changed the site collection administrator of the restored site as it was still pointing to the production server’s site collection administrator.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Then I tried to browse the site and found the interesting error “Cannot make a cache safe URL for &amp;quot;1031/styles/Themable/corev4.css&amp;quot;, file not found. Please verify that the file exists under the layouts directory.” The very first thing I noticed the path contains 1031. Anyone can guess that this is language id and thought came to my mind is that my client SharePoint site not in English. The production site was in German language and when I restored the site, its looking for resources in German language ID folder.&lt;/p&gt;  &lt;p&gt;Then I download the language pack from MSND and refreshed the browser. It worked like magic….&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-7765752360571542419?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/7765752360571542419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-error-cannot-make-cache.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7765752360571542419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/7765752360571542419'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-error-cannot-make-cache.html' title='SharePoint 2010 Error: Cannot make a cache safe URL for &amp;quot;1031/styles/Themable/corev4.css&amp;quot;, file not found. Please verify that the file exists under the layouts directory.'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6113792931967943473</id><published>2010-11-07T13:19:00.000+01:00</published><updated>2010-11-07T13:20:20.482+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010 Error: System.Web.HttpException: Directory 'C:\inetpub\wwwroot\wss\VirtualDirectories\80\_catalogs\masterpage' does not exist.</title><content type='html'>&lt;p&gt;I had got the error when I tried to use pagemethods in SharePoint. I had registered the AjaxControlToolkit namespace in masterpage and then I replace ScriptManager with AjaxControlToolkit’s ToolkitScriptManager as shown below:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ajaxToolkit:ToolkitScriptManager&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ScriptManager&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;EnablePageMethods&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;EnablePartialRendering&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;EnableScriptGlobalization&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;false&amp;quot;&lt;/span&gt;   &lt;span class="attr"&gt;EnableScriptLocalization&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The problem was I enabled the pagemethods by setting EnablePageMethos to true. Disabling the pagemethods fixed the issue. However I didn’t explore why there’s the error if pagemethods is enabled.&lt;/p&gt;

&lt;p&gt;So disable the pagemethods by setting EnablePageMethods=”false” and then then error will disappear…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6113792931967943473?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6113792931967943473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-error.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6113792931967943473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6113792931967943473'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-error.html' title='SharePoint 2010 Error: System.Web.HttpException: Directory &amp;#39;C:\inetpub\wwwroot\wss\VirtualDirectories\80\_catalogs\masterpage&amp;#39; does not exist.'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8383114839393779475</id><published>2010-11-06T19:26:00.000+01:00</published><updated>2010-11-06T19:27:35.748+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Deployment'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint Restore Error: Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version '14.0.0.5050' or later.</title><content type='html'>&lt;p&gt;I had needed to move my dev environment from one Virtual machine to another. So I took backup from source server and tried to restore the backup in new server. However, I have got the error “Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version '14.0.0.5050' or later.” I was totally confused as I had the same version of SharePoint in both server. Then I double checked the version and it was 14.0.4762.1000 for both servers. &lt;/p&gt;  &lt;p&gt;Getting confused I googled and found that solution. This is a bug which is fixed by SharePoint 2010 August cumulative update. The updates are available in the following link:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;For SharePoint Foundation &lt;a href="http://support.microsoft.com/kb/2266423"&gt;http://support.microsoft.com/kb/2266423&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;For SharePoint Server &lt;a href="http://support.microsoft.com/kb/2276339"&gt;http://support.microsoft.com/kb/2276339&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;After installing the updated the error gone…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8383114839393779475?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8383114839393779475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-restore-error-your-backup-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8383114839393779475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8383114839393779475'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-restore-error-your-backup-is.html' title='SharePoint Restore Error: Your backup is from a different version of Microsoft SharePoint Foundation and cannot be restored to a server running the current version. The backup file should be restored to a server with version &amp;#39;14.0.0.5050&amp;#39; or later.'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5969754852238026887</id><published>2010-11-03T09:42:00.000+01:00</published><updated>2010-11-03T15:08:00.945+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Bug and Error'/><title type='text'>SharePoint 2010: Editing an item whose modified version is in pending for approval, causes runtime exception</title><content type='html'>&lt;p&gt;In SharePoint 2010, You can enable content approval by going to ‘Versioning Settings’ section of list settings page as shown below. The error I’ve found can only be found if we choose “Only Users who can approve items (and the author of the item)” as an option in “Who should see draft items in this list?”.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TNEgorRxjeI/AAAAAAAAAk0/LprFCUdlJFQ/s1600-h/image%5B8%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TNEgpxY1jFI/AAAAAAAAAk4/8URFwkVEy1Y/image_thumb%5B3%5D.png?imgmax=800" width="523" height="401" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Content Approval settings page&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now let’s have a scenario where three users are involved. The first user, say &lt;em&gt;admin&lt;/em&gt;, is in administrator group. There are other two users: &lt;em&gt;contributor1&lt;/em&gt; and &lt;em&gt;contributor2&lt;/em&gt; who belongs to contributor group. Say there’s a list &lt;em&gt;MyList&lt;/em&gt; where Content Approval is enabled for the list and only users who can approve the item and the author of the item can see draft items. Now follow the steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;User &lt;em&gt;contributor1&lt;/em&gt; edits an item. And the draft item is pending for approval by &lt;em&gt;admin&lt;/em&gt; user.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;User &lt;em&gt;contributor2&lt;/em&gt; visit the item and try to edit the item. When user click edit link the edit dialog comes up but when user click Save button the following error message is shown (if you have enabled stack trace):&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TNEgrN6bP-I/AAAAAAAAAk8/qnyhf2FeaeA/s1600-h/image%5B4%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TNEgsLwOAsI/AAAAAAAAAlA/brC0kfWYegk/image_thumb%5B1%5D.png?imgmax=800" width="877" height="476" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Exception when try to edit an already pending item&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The error message is shown below:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;Cannot complete this action.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;Please try again.&amp;lt;nativehr&amp;gt;0x80004005&amp;lt;/nativehr&amp;gt;&amp;lt;nativestack&amp;gt;&amp;lt;/nativestack&amp;gt;      &lt;br /&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;Exception Details: System.Runtime.InteropServices.COMException: Cannot complete this action.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;Please try again.&amp;lt;nativehr&amp;gt;0x80004005&amp;lt;/nativehr&amp;gt;&amp;lt;nativestack&amp;gt;&amp;lt;/nativestack&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;&lt;font style="font-weight: normal"&gt;&lt;/font&gt;&lt;/h4&gt;  &lt;h4&gt;&lt;font style="font-weight: normal"&gt;Expected Behavior&lt;/font&gt;&lt;/h4&gt;  &lt;p&gt;The expected behavior would be to disable the save button for item already in pending approval status. Or there should have an settings page where admin can define what to do for items whose draft version is in pending approval stage. The options could be:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Hide the item from users who can’t see draft items &lt;/li&gt;    &lt;li&gt;Show the item as readonly to users who can not see draft items (so edit link could be disabled for users). &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;&lt;font style="font-weight: normal"&gt;Conclusion&lt;/font&gt;&lt;/h4&gt;  &lt;p&gt;So if an updated item is waiting for approval and if any other user, except the author and user who can approve, try to edit the item, he/she’ll get the error page shown above. The error is only shown when options are selected for viewing draft items by only author and person who can approve items. Though draft item can be edited/viewed by author and approver, other users can see the old item and can edit. So the error is evident if other users try to edit the item.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5969754852238026887?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5969754852238026887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-editing-item-whose.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5969754852238026887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5969754852238026887'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/11/sharepoint-2010-editing-item-whose.html' title='SharePoint 2010: Editing an item whose modified version is in pending for approval, causes runtime exception'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_o7Td6KCGNTA/TNEgpxY1jFI/AAAAAAAAAk4/8URFwkVEy1Y/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-4238944201323178413</id><published>2010-11-02T16:38:00.000+01:00</published><updated>2010-11-02T16:39:14.630+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Bug and Error'/><title type='text'>SharePoint 2010 Runtime Error: “You must fill out all required properties before checking in this document."</title><content type='html'>&lt;p&gt;In SharePoint 2010, you may find two ways the file upload in a library works based on whether you have custom required fields or not.&lt;/p&gt;  &lt;h4&gt;File upload in Document Library with no custom required field&lt;/h4&gt;  &lt;p&gt;By default when a library doesn’t have any required field, after uploading a document, the upload window redirects u to the library view page. So in this case there are two steps as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TI9jvMwol5I/AAAAAAAAAjM/qp_fz8mWV-8/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TI9jxKdGpxI/AAAAAAAAAjQ/VqIAqjiXyXc/image_thumb%5B1%5D.png?imgmax=800" width="904" height="251" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Two steps file upload process for library with not custom required fields&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;File upload in Document Library with custom required field&lt;/h4&gt;  &lt;p&gt;However, if you add a field as required then after uploading a document you will be shown an intermediate dialog window where you can provide values for required fields. The intermediate dialog is shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TI9jy3jTwgI/AAAAAAAAAjU/Lwk1SN7mDkw/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TI9j0icVMPI/AAAAAAAAAjY/7xcHmb8gIUc/image_thumb%5B3%5D.png?imgmax=800" width="714" height="412" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: For library with Required fields, user can see this dialog just after file upload&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now in this window you can enter values for required fields. But what if you don’t enter required field values and just cancel the dialog? In this case the file is checked out by you. You might expect that the dialog should be not canceled without entering required field values. But maybe SharePoint team just wanted to let the user to fill the required fields later on, without forcing to do so in the dialog immediately. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;What if user leave the file checked-out by not entering values for required fields?&lt;/h4&gt;  &lt;p&gt;Now if user doesn’t fill the required fields on the dialog shown on figure 2 by clicking cancel button, then the file is not checked in and kept checked-out by the user who uploaded the file. Now if you select the ‘document’ item in library you can find the check-in button is enabled (shown in the image below) which means the document is checked-out. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TI9j2Awb46I/AAAAAAAAAjc/DtrsTU5HkH0/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TI9j38tXe4I/AAAAAAAAAjg/_hDv-B_lpvI/image_thumb%5B5%5D.png?imgmax=800" width="460" height="262" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: File without filling required fields is checked-out&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;What if you try to check-in the file?&lt;/h4&gt;  &lt;p&gt;Now if you try to check-in the file by clicking “Check In” (as in figure 3), you will get an runtime exception as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_o7Td6KCGNTA/TI9j5fx8p1I/AAAAAAAAAjk/XCWY17zN1cw/s1600-h/image%5B15%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TI9j7ODMehI/AAAAAAAAAjo/WeYCMcPrKs4/image_thumb%5B7%5D.png?imgmax=800" width="556" height="301" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: Runtime exception on file check-in&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h4&gt;What would be the expected behavior?&lt;/h4&gt;  &lt;p&gt;So what would be the expected behavior if user clicked on “Check In'” shown in figure 3? As I can expect that the window shown on figure 2 would be presented to let user know that the required fields are missing. So if user still cancels the dialog the file would be in checked-out state. If user put values for required fields and save then the file can be checked-in.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-4238944201323178413?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/4238944201323178413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-runtime-error-you-must.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4238944201323178413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4238944201323178413'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-runtime-error-you-must.html' title='SharePoint 2010 Runtime Error: “You must fill out all required properties before checking in this document.&amp;quot;'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_o7Td6KCGNTA/TI9jxKdGpxI/AAAAAAAAAjQ/VqIAqjiXyXc/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3714089988948502828</id><published>2010-10-24T10:48:00.001+02:00</published><updated>2010-10-24T10:48:53.280+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint: StaticName, InternalName, DisplayName. Which one to use in case of Multilingual supported site?</title><content type='html'>&lt;p&gt;SharePoint provides three different names for referring a field: DisplayName, Intername and StaticName. You can get more details on these three properties in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.staticname.aspx" target="_blank"&gt;MSDN post&lt;/a&gt;. In short, Display name is what you see in the site. Internal name is the readonly name which is created when the filed in created and can’t be modified i.e., readonly and the name should be unique. Static name doesn’t need to be unique and can be changed. If you don’t change the static name, internal name and static name are same.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Ok, let’s come to point. We used to access list item’s value by using display name as shown below:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;var value = ListItem[DisplayName]&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The problem in this approach is that if display name can be different for different language. So using display name can work in a language but may not work in different language. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Problem I experienced in using Display name&lt;/h4&gt;  &lt;p&gt;I was working on content approval related stuffs. And I had found the approval status is kept in a field whose display name is ‘Approval Status’. So I had used code like shown below to get the approval status field value.&lt;/p&gt;  &lt;p&gt;ListItem[‘Approval Status’]&lt;/p&gt;  &lt;p&gt;Unfortunately, my client was using German version and when I deployed I found my code is not working. After spending some time I had figured out the column ‘Approval Status’ is missing in the list. And I finally figured out the column name is not ‘approval status’ but it’s German equivalent. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;So, which one to use from InternalName, StaticName, DisplayName?&lt;/h4&gt;  &lt;p&gt;So which field to use when? If you need to access custom field created by you or your team, you can use display name (considering you are using different display name for different language) . If you are using any SharePoint provided field then better to use StaticName or Intername, since you are not sure if the display name will be changed or not.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-3714089988948502828?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/3714089988948502828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-staticname-internalname.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3714089988948502828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3714089988948502828'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-staticname-internalname.html' title='SharePoint: StaticName, InternalName, DisplayName. Which one to use in case of Multilingual supported site?'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-670169701171273277</id><published>2010-10-23T10:32:00.000+02:00</published><updated>2011-11-12T21:09:05.107+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint: Active/Deactivate Feature programmatically</title><content type='html'>&lt;p&gt;Sometimes you may need to activate/deactivate features programmatically. In my case, I needed to do some synchronization from a Synchronization feature. As part of the synchronization, I needed to move data from one list to another. However the destination list had event receiver attached. The event receiver was attached using another feature (say ListItemEventReceiverAttacher). So I needed to deactivate the feature (i.e., ListItemEventReceiverAttacher) to make sure that event receiver associated to the list is not active. So let’s come to the point rather than beating around the bush.&lt;/p&gt;  &lt;p&gt;First of all, your feature can have scope of web, site or webapplication or Farm. so you need to get the feature first. You can do so by accessing Features properties of Site or web as shown below:&lt;/p&gt;  &lt;p&gt;1. Get the activated Features available in the WebApplication/Site/Web level&lt;/p&gt;  &lt;pre class="csharpcode"&gt;var webApplicationFeatures = webapplication.Features
var webFeatures = web.Features;
var siteFeatures = site.Features;&lt;/pre&gt;
&lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;2. once you have got the features you can find your feature by feature id or name, if the feature is activated, as shown below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var feature = site.Features.SingleOrDefault(sf =&amp;gt; sf.DefinitionId == myFeatureDefinitionId);

var feature = site.Features.SingleOrDefault(sf =&amp;gt; sf.Definition.DisplayName.Equals(&lt;span class="str"&gt;&amp;quot;Feature Title&amp;quot;&lt;/span&gt;));&lt;/pre&gt;
&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;If the feature is null then the feature is not activated. Only activated features will be available through site.Features/web.Features property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. If feature is not activated, you can activate the feature&lt;/strong&gt; as shown below:

  &lt;br /&gt;

  &lt;div id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(feature==&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;span style="color: #008000"&gt;//if feature is not activated&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   site.Features.Add(featureId);&lt;span style="color: #008000"&gt;//activate feature&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;

    &lt;br /&gt;&lt;strong&gt;4. If the feature is activated, you can deactivate the feature&lt;/strong&gt; as shown below:&lt;/div&gt;
&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(feature!=&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;span style="color: #008000"&gt;//if feature is activated&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    site.Features.Remove(feature.DefinitionId);&lt;span style="color: #008000"&gt;//deactivate feature&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;font color="#ff0000"&gt;Important:&lt;/font&gt; One important thing to notice that once you activate/deactivate a feature against an object (SPWebApplication/SPSite/SPWeb), you need to open a new SPWebApplication/SPSite/SPWeb object to get the changes you made. The scenario shown below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (SPSite site=&lt;span class="kwrd"&gt;new&lt;/span&gt; SPSite(&lt;span class="str"&gt;&amp;quot;http://myserver&amp;quot;&lt;/span&gt;))
{
    &lt;span class="rem"&gt;//Activate or deactivate feature&lt;/span&gt;
    &lt;span class="rem"&gt;//the changes will not be available in this scope.&lt;/span&gt;
}
&lt;span class="kwrd"&gt;using&lt;/span&gt; (SPSite site=&lt;span class="kwrd"&gt;new&lt;/span&gt; SPSite(&lt;span class="str"&gt;&amp;quot;http://myserver&amp;quot;&lt;/span&gt;))
{
    &lt;span class="rem"&gt;//Changes made to the feature in upper using block will be effeftive here&lt;/span&gt;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-670169701171273277?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/670169701171273277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-activedeactivate-feature.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/670169701171273277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/670169701171273277'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-activedeactivate-feature.html' title='SharePoint: Active/Deactivate Feature programmatically'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-550766281323700815</id><published>2010-10-18T10:40:00.001+02:00</published><updated>2010-10-18T10:40:31.944+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Get Current page’s Url. Request.Url vs SPUtility.GetPageUrlPath</title><content type='html'>&lt;p&gt;Few days back while I was working on SharePoint application page, I had needed to get the current page’s url. I’m used to using Request.Url to get the current page url and used Request.Url in several places. But interestingly, when I tried to get the current page url from application page, it was giving me the root web’s url (like &lt;a href="http://mysharepoint/_layouts/pages/mypage.aspx"&gt;http://mysharepoint/_layouts/pages/mypage.aspx&lt;/a&gt;) whereas my actual page’s url was something like &lt;a href="http://mysharepoint/subsite/_layouts/pages/mypage.aspx"&gt;http://mysharepoint/subsite/_layouts/pages/mypage.aspx&lt;/a&gt;. The Request.Url was just skipping the SPWeb name.&lt;/p&gt;  &lt;p&gt;Then I tried the SharePoint’s SPUtility.GetPageUrlPath and found the actual url. Though the Request.RawUrl returns the relative url which includes the subsite name but it seems safe to use SPUtility.GetPageUrlPath method to get current page’s url to make sure the page is valid and we can trust SharePoint API more in SharePoint context rather than fully relaying on asp.net built-ins.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-550766281323700815?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/550766281323700815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-get-current-pages-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/550766281323700815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/550766281323700815'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-get-current-pages-url.html' title='SharePoint 2010: Get Current page’s Url. Request.Url vs SPUtility.GetPageUrlPath'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3779966612874548876</id><published>2010-10-13T10:21:00.000+02:00</published><updated>2010-10-13T10:22:05.956+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint 2010: Delete webpart Title (remove untitled title)</title><content type='html'>&lt;p&gt;When you add a webpart in a page, the webpart title is shown. But sometimes we want to delete/hide the webpart. To remove the webpart title, we can edit the webpart and remove the title from webpart edit toolbox. Unfortunately, if you remove the webpart title, you’ll find a default webpart title ‘Untitled’ is added.&lt;/p&gt;  &lt;p&gt;To remove ‘untitled’ title, edit the title of the webpart and put an empty string (or or more spaces) in the tile. This will show the title but as empty string is shown, it can’t be seen.&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TLVsI66eeuI/AAAAAAAAAkc/_gfvPBj14wY/s1600-h/image%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TLVsJ2i4-3I/AAAAAAAAAkg/wBZkqvqxu5g/image_thumb.png?imgmax=800" width="99" height="108" /&gt;&lt;/a&gt;           &lt;br /&gt;Figure 1: Deleting Title&lt;/td&gt;        &lt;td valign="top" width="200"&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TLVsKfEDfdI/AAAAAAAAAkk/UjardLd4R08/s1600-h/image%5B8%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TLVsLOZfRYI/AAAAAAAAAko/mR4pYkb5mKU/image_thumb%5B2%5D.png?imgmax=800" width="90" height="109" /&gt;&lt;/a&gt;           &lt;br /&gt;Figure 2: empty title (space)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As shown in the image above, if you put empty space in title the title can’t be seen and it seems there’s no title.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-3779966612874548876?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/3779966612874548876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-delete-webpart-title.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3779966612874548876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3779966612874548876'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-delete-webpart-title.html' title='SharePoint 2010: Delete webpart Title (remove untitled title)'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TLVsJ2i4-3I/AAAAAAAAAkg/wBZkqvqxu5g/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-8092424195780830202</id><published>2010-10-12T10:32:00.000+02:00</published><updated>2010-10-12T10:34:50.753+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>SharePoint Long running tasks/Operations: Timer Job or SPLongOperation</title><content type='html'>&lt;p&gt;When you need to perform some operations in a webpart and the operation may take few minutes, you have two options to choose from. One might be Timer job. Clicking on a button in the webpart will start the timer job and you can check the job status periodically and show the status on the page. Timer job is perfect for long running operation but showing status in UI while the job is running might be a bit hard.&lt;/p&gt;  &lt;p&gt;Another option might be to use SPLongOperation class of SharePoint to run long operation while to show user meaningful message. SPLongOperation is a good choice when you want to run an operation that takes few minutes only and when the user is trusted ( I mean the user is trusted to wait while the operation in progress by seeing the wait screen rather than refreshing the page). As shown in the following code snippet, you can create a SPLongOperation instance and put the long running code between SPLogOperation.Begin() and SPLongOperaiton.End() method invocation. In the end operation you need to specify the url the page will be redirected to once the operation is done. This might be the same page url or different page’s url.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;var longOperation=&lt;span class="kwrd"&gt;new&lt;/span&gt; SPLongOperation(&lt;span class="kwrd"&gt;this&lt;/span&gt;.Page);
longOperation.LeadingHTML = &lt;span class="str"&gt;&amp;quot;Please wait while the operation is running&amp;quot;&lt;/span&gt;;
longOperation.TrailingHTML = &lt;span class="str"&gt;&amp;quot;Once the operation is finished you will be redirected to result page&amp;quot;&lt;/span&gt;;
longOperation.Begin();

&lt;span class="rem"&gt;//Do long operation here&lt;/span&gt;
Thread.Sleep(10000);

longOperation.End(&lt;span class="str"&gt;&amp;quot;Result.aspx&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;As as result of the above code you can see the following screen during the operation is progress.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TLQdpa4p0pI/AAAAAAAAAkU/0ZBgrbrFgsQ/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TLQdqbf3ONI/AAAAAAAAAkY/GGs1IgOblls/image_thumb%5B1%5D.png?imgmax=800" width="586" height="246" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Even when you are not sure how much time a page takes to load you can use the SPLongOperation interface which may provide better user experience. So if your operation needs several minutes or more your choice might be Timer job. But the operation takes few minutes and the operation needs user interaction then you can opt to use SPLongOperation.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-8092424195780830202?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/8092424195780830202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-long-running-tasksoperations.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8092424195780830202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/8092424195780830202'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-long-running-tasksoperations.html' title='SharePoint Long running tasks/Operations: Timer Job or SPLongOperation'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TLQdqbf3ONI/AAAAAAAAAkY/GGs1IgOblls/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3815611400442234994</id><published>2010-10-11T11:04:00.000+02:00</published><updated>2010-10-24T10:31:58.786+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Receiver'/><title type='text'>SharePoint 2010: Send Notification on Item Approved/Rejected (when Content Approval Status is changed)</title><content type='html'>&lt;p&gt;In SharePoint 2010 new improvements are made for better event receiving management. Few new event handlers are added for site, web, list, listitems etc. However, One thing that I think badly needed was the content approval events&amp;#160; for list items.&lt;/p&gt;  &lt;p&gt;Nowadays content approval has become an integral part of content management system. Requirements has come up to do more work on content approval/reject. But unfortunately, SharePoint list/library doesn’t have events like ContentApproved, ContentRejected, ContentRequestedForReview so that user can tap the events to do their own work on content approval status changes. So it seems we need to do a lot of works manually to send notifications on content approval status changes.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Problem: Approving Status change events Missing&lt;/h4&gt;  &lt;p&gt;One of my client wanted to get notification on the following scenarios:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1. On Item Add/Update:&lt;/strong&gt; If a user edit an item and item goes to pending status as the item needs approval, the approving teams need to be notified that an item is waiting for their approval.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2. On Item Approved&lt;/strong&gt;: If the approving team approve the item,the user who added/updated the item needs to be notified.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3. On Item rejected:&lt;/strong&gt; If the approving team reject the item, the user who added/updated the item needs to be notified with reasons why the item rejected.&lt;/p&gt;  &lt;p&gt;But the SharePoint Object Model doesn’t have the extensibility at this point where approving status changes. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Why Approval Status change event missing?&lt;/font&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The best solution would be if SharePoint team would provide us with out-of-box events for content approval. In that case, two events would be suffice. The events might be : ContentApprovingStatusChanging and ContentApprovingStatusChanged and the event argument’s AfterProperties and BeforeProperties values could be filled with the the old value and new value of Content Approving Status field value. However, one may argue that ItemAdded/ItemUpdate events are similar like Content Approval events. So when user add/edit an item and as part of the add/edit if approval status field get updated then which events to fire? ItemAdded/ItemUpdate or content approval events. Hmm.. maybe there’s complexities with the new content approval events and SharePoint team has not added the new content approval events.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;&amp;#160;&lt;/h4&gt;  &lt;h4&gt;Resolution: Use ItemAdded, ItemUpdating and ItemUpdated events to keep track of approval status changing&lt;/h4&gt;  &lt;p&gt;So consider now the problem we’re going to talk about. We need a notification system where we need to send notification to the approver or user (who is waiting for approval) on approval status change. We’ll develop a list item event receiver for ItemAdded and ItemUpdated events. When a new item will be added it’s easy to identify item status and if the status is pending then we can send notification to all people in the approving team. But when an Item is updated, you need to keep track of if the Approving status field value is changed, if so then u need to send notification. However, you can only get the old approval status field value in ItemUpdating event, but you don’t want to send notification in ItemUpdating. So it’s safe to send notification in ItemUdated event but in ItemUpdated event you’ll not get the old value. You can access the old value in ItemUpdating. So here’s the deal:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a new field say OldStatus in the list. This field will be used to keep track of if the approval status field value has been changed. &lt;/li&gt;    &lt;li&gt;In ItemUpdating event, set the current approval status (before updating) to OldStutus field. &lt;/li&gt;    &lt;li&gt;In ItemUpdated, compare the current status to OldStatus field value and if they are not same then it’s for sure that the approval status has been changed. So send notification. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So let’s go with the steps. First we need an List Event Receiver that will listen three events of the list: ItemAdded, ItemUpating and ItemUpdated. You need to send notification on two events: ItemAdded and ItemUpdated. However, we need to hook the event ItemUpdating to know whether the approval status is going to be changed&lt;/p&gt;  &lt;p&gt;&lt;font style="background-color: #ffff00"&gt;&lt;strong&gt;Create a List Event Receiver to send notification&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Send notification on Item Added&lt;/strong&gt;       &lt;blockquote&gt;       &lt;p&gt;On Item added event, check if the item status is pending. If so then send notification. The following code snippet may give you the gist.&lt;/p&gt;        &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ItemAdded(SPItemEventProperties properties)
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; approvalStatusFieldInternalName = &lt;span class="str"&gt;&amp;quot;_ModerationStatus&amp;quot;&lt;/span&gt;;

    var list = properties.List;
    var approvalStatuField = list.Fields.GetFieldByInternalName(approvalStatusFieldInternalName);
    var approvalStatusFieldValue = properties.ListItem[approvalStatuField.Id];
    var approvalStatus = (approvalStatusFieldValue == &lt;span class="kwrd"&gt;null&lt;/span&gt;) ? &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty :
                            approvalStatusFieldValue.ToString();
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (approvalStatus == &lt;span class="str"&gt;&amp;quot;Pending&amp;quot;&lt;/span&gt;)
    {
        &lt;span class="rem"&gt;//SendNotification()&lt;/span&gt;
    }
}&lt;/pre&gt;
      &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Keep track of the approval status field value (before updated) on Item Updating event&lt;/strong&gt; 

    &lt;blockquote&gt;
      &lt;p&gt;I’m assuming that you have a field OldStatus where I’ll keep the approval status field value which is going to be changed. I’ll explain later in this post how to automatically add the field in list. But for now just take for granted that you have a field OldStatus in your list of type string. The following code show how to keep the approval status (before update) value in OldStatus field in ItemUpdating Event.&lt;/p&gt;

      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ItemUpdating(SPItemEventProperties properties)
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; approvalStatusFieldInternalName = &lt;span class="str"&gt;&amp;quot;_ModerationStatus&amp;quot;&lt;/span&gt;;

    var list = properties.List;
    var approvalStatuField = list.Fields.GetFieldByInternalName(approvalStatusFieldInternalName);
    var approvalStatusFieldValue = properties.ListItem[approvalStatuField.Id];
    var approvalStatusValue = (approvalStatusFieldValue == &lt;span class="kwrd"&gt;null&lt;/span&gt;) ? &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty :
                approvalStatusFieldValue.ToString();

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;.IsNullOrEmpty(approvalStatusValue)) &lt;span class="kwrd"&gt;return&lt;/span&gt;;

    EventFiringEnabled = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    properties.ListItem[&lt;span class="str"&gt;&amp;quot;OldStatus&amp;quot;&lt;/span&gt;] = approvalStatusValue;
    properties.ListItem.SystemUpdate(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
    EventFiringEnabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
}&lt;/pre&gt;
      &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Check the OldStatus field value and current approval status value to know if the approval status changed.&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;Item updated is fried once the update is done. So we’ll get the updated value of Approval Status. But fortunately, we have kept the old value of Approval Status field in OldStatus field during ItemUpdating event as shown in step 2.&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ItemUpdated(SPItemEventProperties properties)
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; approvalStatusFieldInternalName = &lt;span class="str"&gt;&amp;quot;_ModerationStatus&amp;quot;&lt;/span&gt;;
    var list = properties.List;
    

    var approvalStatusField = list.Fields.GetFieldByInternalName(approvalStatusFieldInternalName);
    var currentStatuFieldValue = properties.ListItem[approvalStatusField.Id];
    var currentStatus = (currentStatuFieldValue == &lt;span class="kwrd"&gt;null&lt;/span&gt;) ? &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty : 
                        currentStatuFieldValue.ToString();

    var oldStatusFieldValue = properties.ListItem[&lt;span class="str"&gt;&amp;quot;OldStatus&amp;quot;&lt;/span&gt;];
    var oldStatus = (oldStatusFieldValue == &lt;span class="kwrd"&gt;null&lt;/span&gt;) ? &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty : oldStatusFieldValue.ToString();

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;.IsNullOrEmpty(oldStatus) &amp;amp;&amp;amp; oldStatus != currentStatus)
    {
        &lt;span class="rem"&gt;//SendNotification();&lt;/span&gt;
    }
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;Create a feature receiver to attached List Event Receiver and to create field OldStatus&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;font style="font-size: 10pt"&gt;&lt;/font&gt;Finally We need an feature receiver (not list event receiver) which will do two works: Attached our list event receiver to a list and create a field OldStatus in the list. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;FeatureActivating Event&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;In FeatureActivating you need to check first if the event is already registered. If not registered then register the event. Also make sure the list has OldStatus field. In the code below, listNeedsToAttachedNotitificationReceivers is array of list names which needs to attach the event receivers. &lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties properties)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt;[] listNeedsToAttachedNotitificationReceivers = { &lt;span class="str"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Order&amp;quot;&lt;/span&gt; };
    var myAssemblyName = &lt;span class="str"&gt;&amp;quot;MyProject.SharePoint&amp;quot;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var listName &lt;span class="kwrd"&gt;in&lt;/span&gt; listNeedsToAttachedNotitificationReceivers)
    {
        var web = properties.Feature.Parent &lt;span class="kwrd"&gt;as&lt;/span&gt; SPWeb;
        var list = web.Lists[listName];
        SPEventReceiverDefinitionCollection spEventReceiverDefinitionCollection = list.EventReceivers;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (!IsEventReceiverAlreadyAttached(spEventReceiverDefinitionCollection, myAssemblyName))
        {
            &lt;span class="rem"&gt;//Attach three ItemAdded, ItemUpdating and itemUpdated event receivers&lt;/span&gt;
            SPEventReceiverType eventReceiverType = SPEventReceiverType.ItemAdded;
            spEventReceiverDefinitionCollection.Add(eventReceiverType, 
                Assembly.GetExecutingAssembly().FullName, 
                &lt;span class="str"&gt;&amp;quot;MyProject.SharePoint.Receivers.ListItem.ContentApprovalEventHandler&amp;quot;&lt;/span&gt;);
            eventReceiverType = SPEventReceiverType.ItemUpdated;
            spEventReceiverDefinitionCollection.Add(eventReceiverType, 
                Assembly.GetExecutingAssembly().FullName, 
                &lt;span class="str"&gt;&amp;quot;MyProject.SharePoint.Receivers.ListItem.ContentApprovalEventHandler&amp;quot;&lt;/span&gt;);
            eventReceiverType = SPEventReceiverType.ItemUpdating;
            spEventReceiverDefinitionCollection.Add(eventReceiverType, 
                Assembly.GetExecutingAssembly().FullName, 
                &lt;span class="str"&gt;&amp;quot;MyProject.SharePoint.Receivers.ListItem.ContentApprovalEventHandler&amp;quot;&lt;/span&gt;);
            list.Update();
        }
        EnusureOldStatusFieldExists(list);
    }
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsEventReceiverAlreadyAttached(SPEventReceiverDefinitionCollection spEventReceiverDefinitionCollection, &lt;span class="kwrd"&gt;string&lt;/span&gt; myAssemblyName)
{
    &lt;span class="kwrd"&gt;bool&lt;/span&gt; eventReceiverAttached = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; spEventReceiverDefinitionCollection.Count; i++)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (spEventReceiverDefinitionCollection[i].Assembly.Contains(myAssemblyName))
        {
            eventReceiverAttached = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        }
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; eventReceiverAttached;
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; EnusureOldStatusFieldExists(SPList list)
{
    var field = list.Fields.TryGetFieldByStaticName(&lt;span class="str"&gt;&amp;quot;OldStatus&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (field == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        list.Fields.Add(&lt;span class="str"&gt;&amp;quot;OldStatus&amp;quot;&lt;/span&gt;, SPFieldType.Text, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
        list.Update();
    }
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;
&lt;style type="text/css"&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Feature Deactivating Event&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;In feature deactivating event, unregister the list event receivers. If you want you can delete the OldStatus field. However I have not deleted the field in the code below:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FeatureDeactivating(SPFeatureReceiverProperties properties)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt;[] listNeedsToAttachedNotitificationReceivers = { &lt;span class="str"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;Order&amp;quot;&lt;/span&gt; };
    var myAssemblyName = &lt;span class="str"&gt;&amp;quot;MyProject.SharePoint&amp;quot;&lt;/span&gt;;


    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var listName &lt;span class="kwrd"&gt;in&lt;/span&gt; listNeedsToAttachedNotitificationReceivers)
    {
        var receiversToRemove = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Guid&amp;gt;();
        var web = properties.Feature.Parent &lt;span class="kwrd"&gt;as&lt;/span&gt; SPWeb;
        var list = web.Lists[listName];
        SPEventReceiverDefinitionCollection spEventReceiverDefinitionCollection = list.EventReceivers;
        &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; spEventReceiverDefinitionCollection.Count; i++)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (spEventReceiverDefinitionCollection[i].Assembly.Contains(myAssemblyName))
            {
                receiversToRemove.Add(spEventReceiverDefinitionCollection[i].Id);
            }
        }
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (receiversToRemove.Count &amp;gt; 0)
        {
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var guid &lt;span class="kwrd"&gt;in&lt;/span&gt; receiversToRemove)
            {
                list.EventReceivers[guid].Delete();

            }
            list.Update();
        }
    }
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;






.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;&lt;/blockquote&gt;

&lt;h4&gt;How it works all together?&lt;/h4&gt;

&lt;p&gt;It’s a bit complex huh? oK, let’s me explain how it works. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The feature receiver needs to be activated first. The feature receiver attached the event receiver to list and create a string field OldStatus in the list. &lt;/li&gt;

  &lt;li&gt;Next if an item is added to the list, the listItem event gets fired and if the item status is pending (means needs approval) then send notification. &lt;/li&gt;

  &lt;li&gt;If an existing item is edited and saved then ItemUpdating event is fired. This is the event where the item is not yet saved. So I have put the current approval status in the OldStatus field. In ItemUpated event I have compared the OldStatus and current status field value. If the valued doesn’t match then the approval status is changed and we need to send the notification. &lt;/li&gt;
&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-3815611400442234994?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/3815611400442234994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-content-approval-events.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3815611400442234994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3815611400442234994'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-2010-content-approval-events.html' title='SharePoint 2010: Send Notification on Item Approved/Rejected (when Content Approval Status is changed)'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-708456796319539176</id><published>2010-10-02T10:32:00.000+02:00</published><updated>2010-10-02T10:35:35.839+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint Designer 2010: Crash frequently, not a product for public release</title><content type='html'>&lt;p&gt;I can remember the old days of using SharePoint Designer 2007. SharePoint Designer 2007 used to crash so frequently that before pressing Ctrl + S&amp;#160; (for saving content) in SharePoint designer I prayed to God not to crash the designer. I can still fell the pain and danger I used to face in those old days. I couldn’t understand how a public released product can crash so frequently! Even a beta product can’t be that much unstable nowadays. However SharePoint designer 2007 was made a bit stable later with service pack releases.&lt;/p&gt;  &lt;p&gt;SharePoint 2010 is out there for few months and people are rushing for it (as it seems). My expectation was not to face the same buggy designer this time. &lt;font color="#ff0000"&gt;But I’m disappointed and frustrated as like others who have experience the same problems&lt;/font&gt;. I’ve been using SharePoint Designer for few weeks and I’ve found it’s crashing&amp;#160; frequently (but not that much as was in first release of of Designer 2007). And the most interesting is that there’s no error reporting option in SharePoint Designer. It just crashes and when I open the designer again it opens as it nothing unusual happened before. &lt;/p&gt;  &lt;p&gt;Since there’s no alternative to SharePoint designer, so we are bound to use the designer risking the chance of losing the content and valuable time. We don’t expect this to be happen again and again.There’s lot of reports on SP designer crash on web. We SharePoint community expect reasonable steps from SharePoint team to resolve the issue. Now either Microsoft can make the project open source or they can fix it by themselves. When it continue crashing again and again It seems like the product was developed by some fresh university students for their final year projects.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Working with SharePoint Designer is too much frustrating, disgusting experience. SharePoint designer should be part of SharePoint but it seems SharePoint Team doesn’t think like that way. They always care less about SharePoint designer than the original product and getting less care from the team SharePoint designer becomes a playing tools that can be used to demonstrate how a product can be crashed shamelessly. SharePoint Designer is less cared by-product from SharePoint team. But SharePoint Team should know, the designer is the product that can be used to edit content in SharePoint and we are using SharePoint Designer to add/edit enterprise content not some testing stuffs. So I loose my contents or my contents get distorted then they are responsible for this.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-708456796319539176?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/708456796319539176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-designer-2010-crash.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/708456796319539176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/708456796319539176'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/10/sharepoint-designer-2010-crash.html' title='SharePoint Designer 2010: Crash frequently, not a product for public release'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-785454902668484545</id><published>2010-09-23T10:57:00.001+02:00</published><updated>2010-09-23T14:52:51.768+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Add custom menuitem to Welcome/My Settings (top-right) menu</title><content type='html'>&lt;p&gt;To add a custom menu or hide an existing menu in SharePoint you need associate a element.xml file with a feature. My pervious blog post descries &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-development-with-visual.html"&gt;how to add an element.xml file and associate it with a feature&lt;/a&gt;. The element.xml file has the following structure:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;CustomAction&lt;/span&gt;
  &lt;span class="attr"&gt;Id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;myCustomAction&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;GroupId&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;GROUP_ID&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Location&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MENU_LOCATION&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Sequence&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1000&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Open Your Page&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Open Your custom page&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UrlAction&lt;/span&gt; &lt;span class="attr"&gt;Url&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;~site/SitePages/mypage.aspx&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;CustomAction&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;As shown in the code snippet above, Id is the name of the action. GroupId is the sharepoint defined GroupId and Location is also sharePoint defined location. Sequence will define the sequence number of the menu item. Url Action is the page where user will be navigated when user will click the menu. &lt;/p&gt;

&lt;p&gt;To add custom menu item on the welcome or my settings menu, you need to add an element.xml file (shown below) in the project and need to associate the element.xml file with a feature. In my previous blog post I have described &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-development-with-visual.html"&gt;how to add an Element.xml file and attach the xml file with a feature&lt;/a&gt;.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/sharepoint/&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;CustomAction&lt;/span&gt;
  &lt;span class="attr"&gt;Id&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;myCustomAction&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;GroupId&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;PersonalActions&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Location&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Microsoft.SharePoint.StandardMenu&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Sequence&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1000&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Open Your Page&amp;quot;&lt;/span&gt;
  &lt;span class="attr"&gt;Description&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Open Your custom page&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UrlAction&lt;/span&gt; &lt;span class="attr"&gt;Url&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;~site/SitePages/MyPage.aspx&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;CustomAction&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Elements&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;After using the above Element.xml file you can get the following menu item added on the Welcome/My settings menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TJtNnGpcqSI/AAAAAAAAAkE/DGnTT_D1PT0/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TJtNoSeEwTI/AAAAAAAAAkI/FxWs2zQTiQU/image_thumb%5B1%5D.png?imgmax=800" width="270" height="248" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can get a set of groupid and location values for SharePoint from &lt;a href="http://msdn.microsoft.com/en-us/library/bb802730.aspx"&gt;this MSDN link&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-785454902668484545?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/785454902668484545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-add-custom-menuitem-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/785454902668484545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/785454902668484545'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-add-custom-menuitem-to.html' title='SharePoint 2010: Add custom menuitem to Welcome/My Settings (top-right) menu'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TJtNoSeEwTI/AAAAAAAAAkI/FxWs2zQTiQU/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-2519902370563773370</id><published>2010-09-22T10:31:00.000+02:00</published><updated>2010-11-10T10:01:58.496+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010 Development with Visual Studio 2010: Add Resources (like Elements.xml) to Feature</title><content type='html'>&lt;p&gt;We all SharePoint developers are familiar with Feature.xml and Elements.xml files. We usually defines feature’s resources in Element files. However, in Visual Studio 2010 to add Elements file to Feature we need to do few extra works. You can’t just add the Elements files directly in a feature folder in Visual Studio. You may still need to add the Feature element manifest file, for example in cases where you want to add a custom menu or hide existing menu for site actions. The following steps show how to add Elements.xml file in a SharePoint Feature from Visual Studio 2010.&lt;/p&gt;  &lt;h4&gt;Step 1: Create a new Feature&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;Create a feature for which you want to add the Element manifest file. If you have the feature already, then you can the feature to be used for attaching Element.xml file.&lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;Step 2: Add Empty Element File&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;You need to add an empty element file in the project. To add Element.xml file, create a Empty Elements file in the project from ‘Add new Item’ window as shown below:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TJm-_ZtNrTI/AAAAAAAAAj0/JIfnbUZdDHc/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TJm_A5S8biI/AAAAAAAAAj4/2epFOB5NqTs/image_thumb%5B1%5D.png?imgmax=800" width="800" height="453" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;For manageability, you can keep all Element files in a single folder, say “FeatureElements” folder. &lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;Step 3: Add ElementFile to elements.xml&lt;/h4&gt;  &lt;p&gt;Now, let’s say you want to add a configuration xml file (say MyConfig.xml) to element file. To do so right click on the newly created empty element and add a new item or existing item. Then open the properties of the new/existing item (so, MyConfig.xml) and set the ‘Deployment Type’ to ElementFile.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TNpecwht1TI/AAAAAAAAAlM/He_qo8vP8iI/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TNpeeIgoXgI/AAAAAAAAAlQ/nWeN6CAK2WY/image_thumb%5B5%5D.png?imgmax=800" width="342" height="478" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Step 4: Attach Elements file to Feature&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;Now you need to attach the Element file to a feature. To do so open the feature designer by double clicking on the feature name from Visual Studio’s solution explorer. Then make sure your Element file is on the right side (Items in the feature) of the designer. The following figure shows the Element file MyFeatureElement is attached with the feature whereas YourFeatureElemet is not attached.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TJm_BkbK84I/AAAAAAAAAj8/rmVtkuxNyzY/s1600-h/image%5B91%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TJm_C0CwB4I/AAAAAAAAAkA/TEokndwZYnA/image_thumb%5B85%5D.png?imgmax=800" width="644" height="301" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-2519902370563773370?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/2519902370563773370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-development-with-visual.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2519902370563773370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2519902370563773370'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-development-with-visual.html' title='SharePoint 2010 Development with Visual Studio 2010: Add Resources (like Elements.xml) to Feature'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TJm_A5S8biI/AAAAAAAAAj4/2epFOB5NqTs/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-1009562515947237784</id><published>2010-09-21T11:06:00.000+02:00</published><updated>2010-09-21T11:07:29.371+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Deployment'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Change the default Feature installation location from Visual Studio</title><content type='html'>&lt;p&gt;In SharePoint 2007, we used to put the custom features in folder “12\TEMPLATE\FEATURES”. In SharePoint 2010, feature management is mostly done by Visual Studio 2010 UI. We mostly don’t care where the features are installed. However, with surprise I noticed that the feature is installed in the Features folder but not directly under the Features folder. Visual Studio creates a new folder under “14\TEMPLATE\FEATURES” folder and copy the features under that new folder.The name is in the format “&lt;strong&gt;VisaulStudioProjectName_FeatureName&lt;/strong&gt;”. The name comes from feature’s properties and you can change the format. The following image shows the feature properties defining the naming format.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TJh1xs6rZVI/AAAAAAAAAjs/yA6bSW3QetQ/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/TJh1z0beHvI/AAAAAAAAAjw/pGGJ3f9fwjc/image_thumb%5B3%5D.png?imgmax=800" width="806" height="485" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Feature deployment path in properties window&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now if you want to put the features just directly under the ‘14\Template\Feature’ folder, then just the set the ‘Deployment Path’ property value to '&lt;/p&gt;  &lt;h5&gt;$SharePoint.Feature.FileNameWithoutExtension$&lt;/h5&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Maybe sometimes you want to install the feature just under Features folder and in that case changing the deployment path will be helpful.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-1009562515947237784?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/1009562515947237784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-change-default-feature.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1009562515947237784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/1009562515947237784'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-change-default-feature.html' title='SharePoint 2010: Change the default Feature installation location from Visual Studio'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_o7Td6KCGNTA/TJh1z0beHvI/AAAAAAAAAjw/pGGJ3f9fwjc/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-6337130644286884142</id><published>2010-09-21T10:48:00.000+02:00</published><updated>2010-09-21T10:49:25.432+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>Move SharePoint Site/Web From One Development Server to Another</title><content type='html'>&lt;p&gt;Sometimes, we need to move the site from one server to another, usually in development environment. In that case its required few steps to make sure you have moved your site in new server. I have successfully move my sites and I’m pointing here the exact steps that worked for me.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Backup the site or export the web&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;First of all you need to take backup of the site (if you want to move site collection). If you want to move a single site then export the web contents. For site backup use the following command:&lt;/p&gt;    &lt;h5&gt;&lt;font style="background-color: #ffff00"&gt;Backup-SPSite -Identity &lt;/font&gt;&lt;a href="http://MySiteColllection.com"&gt;&lt;font style="background-color: #ffff00"&gt;http://MySiteColllection.com&lt;/font&gt;&lt;/a&gt;&lt;font style="background-color: #ffff00"&gt; -Path &amp;quot;C:\Backup\BackupFile.bak&amp;quot; -Confirm:$false&lt;/font&gt;&lt;/h5&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;For exporting web use the following command.&lt;/p&gt;    &lt;h5&gt;&lt;font style="background-color: #ffff00"&gt;Export-SPWeb –Identity &lt;/font&gt;&lt;a href="http://MySiteCollection.com/myweb"&gt;&lt;font style="background-color: #ffff00"&gt;http://MySiteCollection.com/myweb&lt;/font&gt;&lt;/a&gt;&lt;font style="background-color: #ffff00"&gt; –Path “C:\Backup\BackupFile.cmp” –Confirm:$False&lt;/font&gt;&lt;/h5&gt;    &lt;p&gt;For more on these commands &lt;a href="http://technet.microsoft.com/en-us/library/ff621084.aspx"&gt;follow MSDN link&lt;/a&gt;.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Create Dummy site or web on the destination server to overwrite&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;Before restoring or importing site/web you need to create a dummy site/web on the destination server. In case of site restore, create a new site collection. In case of web import, create a site with the same name and template used in source server’s web.&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Deploy code on the server&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;If possible, then deploy the sharepoint solution (generated from your developer code in Visual Studio) on the destination server. In some case the restore/import operation looks for features/resources on the site/web that is referenced in the backup/export file. So deploying the code on the server make sure the code (that will be finally used in the restored site/web) is on the destination server. If your code has web level feature/resources then use the root web as the default one to deploy code.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Restore or import the site/web&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;Finally you are ready to restore the site. Run the following command to restore a site collection.&lt;/p&gt;    &lt;h5&gt;&lt;font style="background-color: #ffff00"&gt;Restore-SPSite -Identity &lt;/font&gt;&lt;a href="http://MyNewSiteCollection.com"&gt;&lt;font style="background-color: #ffff00"&gt;http://MyNewSiteCollection.com&lt;/font&gt;&lt;/a&gt;&lt;font style="background-color: #ffff00"&gt; -Path &amp;quot;C:\Backup\BackupFile.bak&amp;quot; -Confirm:$false -Force&lt;/font&gt; &lt;/h5&gt;    &lt;p&gt;Run the following import command to import site.&lt;/p&gt;    &lt;h5&gt;&lt;font style="background-color: #ffff00"&gt;Import-SPWeb –Identity &lt;/font&gt;&lt;a href="http://MyNewSieCollection.com/MyNewWeb"&gt;&lt;font style="background-color: #ffff00"&gt;http://MyNewSieCollection.com/MyNewWeb&lt;/font&gt;&lt;/a&gt;&lt;font style="background-color: #ffff00"&gt; –Path “C:\Backup\BackupFile.cmp” –Overwrite –Confirm:$False&lt;/font&gt;&lt;/h5&gt;    &lt;p&gt;For more on these commands &lt;a href="http://technet.microsoft.com/en-us/library/ff621084.aspx"&gt;follow MSDN link&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h4&gt;Check user Permissions&lt;/h4&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;If you restored a site collection then you need to change site collection administrator as the restored site is still pointing to the old site collection administrators (and maybe the administrator is invalid in the new server). From SharePoint central administration site change the site collection administrator to proper one.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Few points to notice&lt;/h4&gt;  &lt;p&gt;When you move the site/web few points need to remember:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If you restore just a web then your import operation may fail saying a feature is not installed on the web/site. This may happen in case where the source site /web’s backup file is referring a resource (say feature) that is not available on the destination server. In this case, make sure your code is deployed properly on the destination server. If you get the error for a particular web, then create a dummy web with the same name as on the source server, on the destination server and then deploy the code on the web and finally try to restore the web. &lt;/li&gt;    &lt;li&gt;In case of web import, make sure you have created the new web on the destination server with the same template. You can’t overwrite a web on destination server with a source one that is using different template. &lt;/li&gt; &lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-6337130644286884142?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/6337130644286884142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/move-sharepoint-siteweb-from-one.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6337130644286884142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/6337130644286884142'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/move-sharepoint-siteweb-from-one.html' title='Move SharePoint Site/Web From One Development Server to Another'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-5325239995790882690</id><published>2010-09-19T17:27:00.001+02:00</published><updated>2010-09-19T17:27:23.439+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint Error: The exported site is based on the template STS#1 but the destination site is based on the template STS#0</title><content type='html'>&lt;p&gt;Today I was trying to export one of my site from one Virtual machine to another. First I took a export of the web from my source server and then I tried to import the content in the destination server. And then the import failed with the error “&lt;strong&gt;&lt;em&gt;The exported site is based on the template STS#1 but the destination site is based on the template STS#0&lt;/em&gt;&lt;/strong&gt;”. I couldn’t remember the template with which I created the source site but I took for granted from the error message that the source and destination web are not created from the same template. After googling I finally found import will only work if source and destination web are created from the same template. In my case the source site was created from Blank Site template (STS#1) but the destination site was created from Team site template (STS#0).&lt;/p&gt;  &lt;p&gt;So I deleted the destination site and recreated with the source template and the import was successful. For full lists of web site templates you can follow &lt;a href="http://blogs.technet.com/b/araviraj/archive/2008/06/18/sharepoint-templates-types.aspx"&gt;Aravindhan’s&lt;/a&gt;&amp;#160; posts.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-5325239995790882690?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/5325239995790882690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-error-exported-site-is-based.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5325239995790882690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/5325239995790882690'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-error-exported-site-is-based.html' title='SharePoint Error: The exported site is based on the template STS#1 but the destination site is based on the template STS#0'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3100183557898546253</id><published>2010-09-12T16:59:00.000+02:00</published><updated>2010-09-12T17:02:10.539+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WebPart'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010 Visual WebPart in Visual Studio: Best practices</title><content type='html'>&lt;p&gt;When we develop visual WebPart in Visual Studio, we may follow some best practices for better management and organization of WebParts. Here are few good practices to follow:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;1. &lt;strong&gt;Group your web parts:&lt;/strong&gt; Set the group property in the Elements.xml file of WebPart to make sure the webparts comes under a specific group. This will make easier to find the webpart from sharepoint site. The following image shows how to modify group property:       &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TIzrJNzfGCI/AAAAAAAAAis/Zl63d4cDt6s/s1600-h/image%5B11%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TIzrMjpNFqI/AAAAAAAAAiw/NQSBrO6zFkY/image_thumb%5B5%5D.png?imgmax=800" width="865" height="295" /&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;strong&gt;Figure 1: WebPart’s group property in Visual Studio&lt;/strong&gt;&lt;/p&gt;      &lt;p&gt;Setting up the group property will show the webparts under ‘Test Group’ as shown below:&lt;/p&gt;      &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/TIzrPLXrDQI/AAAAAAAAAi0/7_1VY4CmLSo/s1600-h/image%5B15%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/TIzrTsLAZ4I/AAAAAAAAAi4/wtk4_4AnUTo/image_thumb%5B7%5D.png?imgmax=800" width="614" height="389" /&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;strong&gt;Figure 2: Webparts under Group.&lt;/strong&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Organize webparts under folder in Visual Studio:&lt;/strong&gt; Often we are uses to create webparts in the root folder of the Visual Studio Projects. As the number of webparts grow, the folder starts to increase and navigability/manageability problem comes to light. One solution is to keep all webparts under a different folder. Another option is to keep related items under a particular folder. For example all items for navigation can be kept under a root folder “Navigation”. The following image shows all webparts are&amp;#160; kept under ‘webparts’ folder.       &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TIzrU0pf8gI/AAAAAAAAAi8/ANE-22YPqno/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TIzrWnNabNI/AAAAAAAAAjA/WvwI2pg3oX8/image_thumb%5B1%5D.png?imgmax=800" width="275" height="248" /&gt;&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;Figure 3: Webparts organized under folders&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Enter descriptive name and description for your webparts:&lt;/strong&gt; As soon you create an webpart, enter descriptive name and descrition. To do so open the file with .webpart extension and modify Title and Description property as shown below:&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TIzrZQA434I/AAAAAAAAAjE/nrU3AOdv4GI/s1600-h/image%5B19%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_o7Td6KCGNTA/TIzrcJz_4AI/AAAAAAAAAjI/4u_jf_rmgIA/image_thumb%5B9%5D.png?imgmax=800" width="855" height="300" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;Figure 4: Title and description of an WebPart.&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-3100183557898546253?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/3100183557898546253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-visual-webpart-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3100183557898546253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/3100183557898546253'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-visual-webpart-in.html' title='SharePoint 2010 Visual WebPart in Visual Studio: Best practices'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_o7Td6KCGNTA/TIzrMjpNFqI/AAAAAAAAAiw/NQSBrO6zFkY/s72-c/image_thumb%5B5%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-4986186554887263199</id><published>2010-09-03T11:27:00.000+02:00</published><updated>2010-09-03T11:29:20.593+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint 2010: Rename Site Url</title><content type='html'>&lt;p&gt;Sometimes in development environment and even in production you may need to rename a site url. For example you have planned a site with URL &lt;a href="http://www.mysite.com"&gt;www.mysite.com&lt;/a&gt; in Development or in Production. Later you have decided to rename the site url to &lt;a href="http://www.yoursite.com"&gt;www.yoursite.com&lt;/a&gt;. There’s no shortcut way to do that in SharePoint. You need to delete the existing web application for url &lt;a href="http://www.mysite.com"&gt;www.mysite.com&lt;/a&gt; and create a new one with url &lt;a href="http://www.yoursite.com"&gt;www.yoursite.com&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1. Backup the site collection first &lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Run the following powershell command to backup site.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font style="background-color: #ffff00"&gt; Backup-SPSite –Identity &lt;strong&gt;SiteUrl&lt;/strong&gt; –Path &lt;strong&gt;BackupLocation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;2. Delete the existing site from central admin.&lt;/strong&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Navigate to central admin and delete the web application including database and IIS site as shown below:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/TIC_0_y75CI/AAAAAAAAAic/vWmELOSmjhk/s1600-h/image%5B3%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TIC_2_u1ysI/AAAAAAAAAig/-u0DQ3N75tE/image_thumb%5B1%5D.png?imgmax=800" width="523" height="443" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;3. Create the a new site with new Url (say &lt;/strong&gt;&lt;a href="http://www.yoursite.com"&gt;&lt;strong&gt;http://www.yoursite.com&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Now create a new web application with the new url in host header as shown below:&lt;/p&gt;    &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_o7Td6KCGNTA/TIC_4uOLXTI/AAAAAAAAAik/1a53UOv7Ov8/s1600-h/image%5B10%5D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_o7Td6KCGNTA/TIC_7qkeQtI/AAAAAAAAAio/7Yw2P0RU64o/image_thumb%5B4%5D.png?imgmax=800" width="606" height="384" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;4. Restore the backup on the new site&lt;/strong&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Finally restore the backup taken on step 1 overwriting the new site collection. Run the following command on powershell command&lt;/p&gt;    &lt;p&gt;&lt;font style="background-color: #ffff00"&gt;Restore-SPSite –Identity &lt;strong&gt;SiteUrl&lt;/strong&gt; –Path &lt;strong&gt;BackupFilePath&lt;/strong&gt; -Force&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-4986186554887263199?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/4986186554887263199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-rename-site-url.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4986186554887263199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/4986186554887263199'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/09/sharepoint-2010-rename-site-url.html' title='SharePoint 2010: Rename Site Url'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_o7Td6KCGNTA/TIC_2_u1ysI/AAAAAAAAAig/-u0DQ3N75tE/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-558369321663804493</id><published>2010-08-29T17:31:00.001+02:00</published><updated>2010-08-29T17:39:00.597+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Ajax'/><title type='text'>Ajax Control Toolkit with SharePoint 2010</title><content type='html'>&lt;p&gt;I had to use Ajax control toolkit with sharepoint and I had download the latest version from codeplex. We usually download latest versions of software because we believe that with latest version we can get more features and more bug-free. I had used Ajax Control Toolkit with SharePoint 2007 and it was much easier to configure and use Ajax Control Toolkit. With that belief in mind I had started using Ajax Control Toolkit in SharePoint 2010 downloading latest version for .net framework 3.5. But I failed&amp;#160; and after investigating I had found the following errors.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;h5&gt;AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.&lt;/h5&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;h5&gt;Sys.registerComponent is not a function&lt;/h5&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#ff0000"&gt;The problem here is that latest versions of Ajax Control Toolkit is more optimized or targeted with .net framework 4.0. Even the Ajax control toolkit for .net framework 3.5 doesn’t work with SharePoint 2010. If you try to use Ajax Control Toolkit for 3.5 with SharePoint 2010, you may get the exceptions shown above.&lt;/font&gt; &lt;/p&gt;  &lt;h4&gt;How to make Ajax Control Toolkit working with SharePoint 2010?&lt;/h4&gt;  &lt;p&gt;Here are the steps to make Ajax Control Toolkit working with SharePoint 2010.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;Download Correct (compatible) version of Ajax Control Toolkit.&lt;/strong&gt;       &lt;p&gt;Since current release of Ajax Control Toolkit doesn’t work with SharePoint 2010, you need to download previous release. Maybe Ajax Control Toolkit team will address this issue and we’ll be able to use current Toolkit version with SharePoint in future. Until the current release is made compatible, please download the &lt;a href="http://ajaxcontroltoolkit.codeplex.com/releases/view/33804"&gt;SharePoint 2010 compatible Ajax Control Toolkit from here&lt;/a&gt;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Add AjaxControlToolkit.dll reference to your project&lt;/strong&gt;       &lt;p&gt;To use the Ajax Control Toolkit in your SharePoint project, add reference to the AjaxControlToolkit.dll in your project. To use the Ajax Control Toolkit in any web part control add the following lines to register the Ajax Control Toolkit namespace.&lt;/p&gt;      &lt;pre class="code"&gt;&lt;span style="background: yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: maroon"&gt;Register &lt;/span&gt;&lt;span style="color: red"&gt;Assembly&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit, Version=3.0.30930.28736,&lt;br /&gt; Culture=neutral,&lt;/span&gt;&lt;span style="color: blue"&gt; PublicKeyToken=28f01b0e84b6d53e&amp;quot; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: red"&gt;Namespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;TagPrefix&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ajaxToolkit&amp;quot; &lt;/span&gt;&lt;span style="background: yellow"&gt;%&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;Remember, here version 3.x version of Ajax Control Toolkit is used instead 3.5.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Add Ajax Control Toolkit ScriptManager in master page.&lt;/strong&gt; 

    &lt;p&gt;Open the Master page in SharePoint Designer. By default the v4.Master file is the default master page can be found “_catalogs/masterpage” folder. Before modifying the master page, keep a backup copy. &lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;First register the Ajax Control Toolkit namespace in the masterpage file by putting the following line at the top of the file: 
        &lt;pre class="code"&gt;&lt;span style="background: yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@ &lt;/span&gt;&lt;span style="color: maroon"&gt;Register &lt;/span&gt;&lt;span style="color: red"&gt;Assembly&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit, Version=3.0.30930.28736,&lt;br /&gt; Culture=neutral, PublicKeyToken=28f01b0e84b6d53e&amp;quot; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: red"&gt;Namespace&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;AjaxControlToolkit&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;TagPrefix&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ajaxToolkit&amp;quot; &lt;/span&gt;&lt;span style="background: yellow"&gt;%&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
      &lt;/li&gt;

      &lt;li&gt;Then remove the ScriptManager registration from the master page by removing the following line: 
        &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;asp&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;ScriptManager &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ScriptManager&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnablePageMethods&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;false&amp;quot;  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: red"&gt;EnablePartialRendering&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;true&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnableScriptGlobalization&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;false&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnableScriptLocalization&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;true&amp;quot;/&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
      &lt;/li&gt;

      &lt;li&gt;Finally Add the following line in place of the above line to register Ajax Control Toolkit 
        &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ajaxToolkit&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: maroon"&gt;ToolkitScriptManager &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;ScriptManager&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;runat&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;server&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnablePageMethods&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;false&amp;quot; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: red"&gt;EnablePartialRendering&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;true&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnableScriptGlobalization&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;false&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;EnableScriptLocalization&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;true&amp;quot;/&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;Register Ajax Control Toolkit namespaces in SharePoint package Designer&lt;/strong&gt;&amp;#160; &lt;p&gt;Finally, you need to register the Ajax Control Toolkit namespace with SharePoint Package designer. Registering Ajax Control Toolkit namespaces will add Ajax Control Toolkit namespaces in web.config’s safecontrol list. First open the Package designer in Visual Studio (Package usually exists under Package folder in Visual Studio). And then click the “Advanced” button in package designer window as shown in the image below. In that advanced tab you can add/edit assemblies to be registered safe as part of the deployment of the solution package. Click Add ==&amp;gt; “Add Existing Assembly”. The following image shows wizard to follow.&lt;/p&gt;

    &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_o7Td6KCGNTA/THp9B_apZYI/AAAAAAAAAiM/LjGMOT16_mY/s1600-h/image%5B23%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_o7Td6KCGNTA/THp9JHYIWoI/AAAAAAAAAiQ/-OqM49Miw2I/image_thumb%5B17%5D.png?imgmax=800" width="804" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;Figure 1: Package Designer’s Advance tab&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;In the “Add existing Assembly” window, add the following namespaces for Ajax Control Toolkit.&lt;/p&gt;

    &lt;table border="1" cellspacing="0" cellpadding="2" width="745"&gt;&lt;tbody&gt;
        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;&lt;strong&gt;Namespace&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;&lt;strong&gt;Type Name&lt;/strong&gt;&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;&lt;strong&gt;Assembly Name&lt;/strong&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit.Design&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit.HTMLEditor&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit.HTMLEditor.Popups&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit.HTMLEditor.ToolbarButton&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;td valign="top" width="340"&gt;AjaxControlToolkit.MaskedEditValidatorCompatibility&lt;/td&gt;

          &lt;td valign="top" width="155"&gt;*&lt;/td&gt;

          &lt;td valign="top" width="248"&gt;AjaxControlToolkit&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;&lt;/table&gt;

    &lt;p&gt;The following image shows the “Add Existing Assembly” window for AjaxControlToolkit dll.&lt;/p&gt;

    &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_o7Td6KCGNTA/THp9LkW_DUI/AAAAAAAAAiU/GUSpx0pn2CQ/s1600-h/image%5B27%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_o7Td6KCGNTA/THp9OTna2ZI/AAAAAAAAAiY/pdG3ZWMtp24/image_thumb%5B19%5D.png?imgmax=800" width="614" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;Figure 2: Add/Edit Existing Assembly window&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;Now you can build and deploy the package and as a result of deployment, Ajax Control Toolkit namespaces will be registered as safe controls in web.config.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;Its really hard to believe that Ajax Control Toolkit’s&amp;#160; latest version doesn’t work with SharePoint. We expect to have the latest version of Ajax Control Toolkit to be compatible with SharePoint 2010. Until then we might have to use an old version of Ajax Control Toolkit.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-558369321663804493?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/558369321663804493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/ajax-control-toolkit-with-sharepoint.html#comment-form' title='27 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/558369321663804493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/558369321663804493'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/ajax-control-toolkit-with-sharepoint.html' title='Ajax Control Toolkit with SharePoint 2010'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_o7Td6KCGNTA/THp9JHYIWoI/AAAAAAAAAiQ/-OqM49Miw2I/s72-c/image_thumb%5B17%5D.png?imgmax=800' height='72' width='72'/><thr:total>27</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-2734234817310033115</id><published>2010-08-21T15:08:00.000+02:00</published><updated>2010-08-21T15:09:33.056+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='Client OM'/><title type='text'>SharePoint 2010: Conditional Scope</title><content type='html'>&lt;p&gt;In my &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-2010-exception-handling.html"&gt;previous post&lt;/a&gt; I had explained about Exception Handling Scope. If you have not read the post already then I’ll suggest you to read the post as the idea behind this scope in SharePoint Client Object Model has been described in that previous post. &lt;/p&gt;  &lt;p&gt;In Client Object Model, if you need to load data based on some condition. But if the condition is based on some server side values then you need to use two different requests. First request will be to get the values from the server to check the condition. Second request will be to load data or not, based on the condition expression value. &lt;/p&gt;  &lt;p&gt;In SharePoint Client Object Model API, there’s a new class called ConditionalScope to load data conditionally. Here’s how to use the ConditionalScope:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;In ConditionalScope constructor pass the ClientContext instance as first parameter. In the second parameter, pass the condition to be evaluated on the server. As shown below, the condition to check is whether the list is hidden or not. &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;var conditionalScope = &lt;span class="kwrd"&gt;new&lt;/span&gt; ConditionalScope(clientContext, () =&amp;gt; !list.Hidden);&lt;/pre&gt;
  &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;The second step is to put the load expression in ConditionalScope’s StartScope method. As shown below, if the list is not hidden, then load the Title of the list. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (conditionalScope.StartScope())
{
    clientContext.Load(list, ol =&amp;gt; ol.Title);
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;In the above statement, the load will be executed if the condition specified in ConditionalScope’s constructor is true (in this case, not hidden).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;Finally, after executing ClientContext.ExecutQuery method, you need to find out if the expression passed in Coditional Scope was true or false. If condition was true then u know the data has been loaded (in this case the title of the list). If the condition was not true then data was not loaded. To check whether the condition evaluated true of false, check conditional scope’s TestResult. Remember, you will only get this property value after executing Executing query to the server. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;clientContext.ExecuteQuery();
&lt;span class="kwrd"&gt;if&lt;/span&gt; (conditionalScope.TestResult.HasValue &amp;amp;&amp;amp; conditionalScope.TestResult.Value)
{
    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Title:&amp;quot;&lt;/span&gt; + list.Title);
}&lt;/pre&gt;
  &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;As shown in the code snippet above, if the TestResult has been evaluated to true then the title property is available.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The whole code will look like below:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;var clientContext = &lt;span class="kwrd"&gt;new&lt;/span&gt; ClientContext(siteUrl);
var web = clientContext.Web;
var list = web.Lists.GetByTitle(listName);

var conditionalScope = &lt;span class="kwrd"&gt;new&lt;/span&gt; ConditionalScope(clientContext, () =&amp;gt; !list.Hidden);


&lt;span class="kwrd"&gt;using&lt;/span&gt; (conditionalScope.StartScope())
{
    clientContext.Load(list, ol =&amp;gt; ol.Title);
}

clientContext.ExecuteQuery();
&lt;span class="kwrd"&gt;if&lt;/span&gt; (conditionalScope.TestResult.HasValue &amp;amp;&amp;amp; conditionalScope.TestResult.Value)
{
    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Title:&amp;quot;&lt;/span&gt; + list.Title);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h4&gt;&amp;#160;&lt;/h4&gt;

&lt;h4&gt;Limitations&lt;/h4&gt;

&lt;p&gt;You can not use Conditional scope in all cases for all operations:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can only load data using Conditional Scope. You can not however call any method or set properties in Conditional Scope’s StartScope method. If you use the ConditionalScope to set properties or to call server side method, you may get the following error:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;h5&gt;Incorrect usage of conditional scope. Some actions, such as setting a property or invoking a method, are not allowed inside a conditional scope.&lt;/h5&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;expression passed in ConditionalScope’s second argument has restrictions. You can not use all kinds of expressions. For example you can not use expression like, list.Fields.Count. However, you can use List.ItemCount. I have not found any documentation on MSDN with the supported expression for ConditionalScope.&lt;/li&gt;

  &lt;li&gt;Before using ConditionalScope.TestResult in your decision to access data, you need to execute Query.&lt;/li&gt;
&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-2734234817310033115?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/2734234817310033115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-2010-conditional-scope.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2734234817310033115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/2734234817310033115'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-2010-conditional-scope.html' title='SharePoint 2010: Conditional Scope'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-929322771592865080</id><published>2010-08-19T15:39:00.001+02:00</published><updated>2011-09-27T08:02:53.608+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint 2010'/><title type='text'>SharePoint Service Locator: Register Singleton Type</title><content type='html'>&lt;p&gt;In my &lt;a href="http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-service-locator.html"&gt;previous post&lt;/a&gt; I have described how to register type with SharePoint Service Locator. Today I’ll explain how to register singleton instance. We usually use Feature Receiver to register types. The following code snippet shows how to register singleton instance.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ServiceLocatorFeatureEventReceiver : SPFeatureReceiver
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties properties)
    {
        var currentSite=properties.Feature.Parent &lt;span class="kwrd"&gt;as&lt;/span&gt; SPSite;
        var serviceLocator = SharePointServiceLocator.GetCurrent();
        var typeMapper = serviceLocator.GetInstance&amp;lt;IServiceLocatorConfig&amp;gt;();
        typeMapper.Site = currentSite;
        typeMapper.RegisterTypeMapping&amp;lt;INonsingletonInterface, NonsingletonType&amp;gt;();
        
        &lt;strong&gt;var singletonTypeMapper = typeMapper &lt;span class="kwrd"&gt;as&lt;/span&gt; ServiceLocatorConfig;&lt;/strong&gt;
        &lt;strong&gt;singletonTypeMapper.RegisterTypeMapping&amp;lt;ISingletonInterface, SingletonType&amp;gt;(&lt;span class="kwrd"&gt;null&lt;/span&gt;, InstantiationType.AsSingleton);&lt;/strong&gt;

        SharePointServiceLocator.Reset();
    }


    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        var currentSite=properties.Feature.Parent &lt;span class="kwrd"&gt;as&lt;/span&gt; SPSite;
        var serviceLocator = SharePointServiceLocator.GetCurrent();
        var typeMapper = serviceLocator.GetInstance&amp;lt;IServiceLocatorConfig&amp;gt;();
        typeMapper.Site = currentSite;
        typeMapper.RemoveTypeMapping&amp;lt;INonsingletonInterface&amp;gt;(&lt;span class="kwrd"&gt;null&lt;/span&gt;);

&lt;strong&gt;        var singletonTypeMapper = typeMapper &lt;span class="kwrd"&gt;as&lt;/span&gt; ServiceLocatorConfig;
        singletonTypeMapper.RemoveTypeMapping&amp;lt;ISingletonInterface&amp;gt;(&lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/strong&gt;

        SharePointServiceLocator.Reset();
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;As shown in above code block, to register singleton instance, you need to cast the IserviceLocatorConfig instance to ServiceLocatorConfig. Then you can specify the InstantiationType.AsSingleton for registering the type as singleton. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When you register a type as singleton, on first request the type will be instantiated and for later requests the instance created on first request will be delivered. However, if IIS is reset then the instance will be destroyed and create anew on first request.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1804865242850018128-929322771592865080?l=ranaictiu-technicalblog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ranaictiu-technicalblog.blogspot.com/feeds/929322771592865080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-service-locator-register.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/929322771592865080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1804865242850018128/posts/default/929322771592865080'/><link rel='alternate' type='text/html' href='http://ranaictiu-technicalblog.blogspot.com/2010/08/sharepoint-service-locator-register.html' title='SharePoint Service Locator: Register Singleton Type'/><author><name>Sohel Rana</name><uri>http://www.blogger.com/profile/15485221969375347012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://3.bp.blogspot.com/_o7Td6KCGNTA/TTsF6oWPZlI/AAAAAAAAAnc/sx9xJXjkVdg/s220/profile.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1804865242850018128.post-3434253030479216453</id><published>2010-08-10T10:08:00.001+02:00</published><updated>2010-08-10T11:09:58.107+02:00</updated><title type='text'>SharePoint 2010: Exception Handling Scope</title><content type='html'>&lt;p&gt;Sometimes in coding we need to make decision based on exception. For example the following code snippet try to enable versioning and folder creation in a list using SharePoint Client Object Model. However, if the list doesn’t exist then the code also create the list.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; EnableListVersioningAndFolderCreation(&lt;span class="kwrd"&gt;string&lt;/span&gt; siteUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; listName, &lt;span class="kwrd"&gt;string&lt;/span&gt; description)
{
    &lt;span class="kwrd"&gt;using&lt;/span&gt;(var clientContext=&lt;span class="kwrd"&gt;new&lt;/span&gt; ClientContext(siteUrl))
    {
        List list = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        &lt;span class="kwrd"&gt;try&lt;/span&gt;
        {
            list = clientContext.Web.Lists.GetByTitle(listName);
            clientContext.Load(list);
            clientContext.ExecuteQuery();
        }
        &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception)
        {
            var listCreationInformation=&lt;span class="kwrd"&gt;new&lt;/span&gt; ListCreationInformation();
            listCreationInformation.Title = listName;
            listCreationInformation.TemplateType = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)ListTemplateType.GenericList;
            listCreationInformation.Description = description;
            list = clientContext.Web.Lists.Add(listCreationInformation);
            clientContext.ExecuteQuery();
        }
        &lt;span class="kwrd"&gt;finally&lt;/span&gt;
        {
            list.EnableVersioning = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            list.EnableFolderCreation = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            list.Update();
            clientContext.ExecuteQuery();
        }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Figure 1: Code snippet using Try/Catch/Finally approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The above scenario is rife in SharePoint programming.&amp;#160; Based on exception you get the sign that something is missing and you need to fill the missing part. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Problem with this try/catch/finally approach&lt;/h4&gt;

&lt;p&gt;The code block shown in Figure 1, is using try/catch/finally approach to apply logic. We can’t change the try/catch approach as for some SharePoint items there’s no way to find if the item (list, library, web) exists or not without getting an exception. So we decide based on exception. However, in Client Object Model we are concerned with the number of requests are sent to the server. In the code snippet of Figure 1, its obvious that the ClientContext.ExecuteQuery can be executed more than once. If ExecutedQuery method in try block is failed then the ExecutedQuery method in catch block is tried and at last finally block ExecutedQuery method is executed. It would be better if we could just call the ExecutedQuery once only. That’s what we are going to get with ExceptionHandlingScope. Also the code block will look much smarter and easier to read with ExceptionHandlingScope.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;How to u
