<?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:blogger='http://schemas.google.com/blogger/2008' 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-1010348719342749753</id><updated>2025-07-19T19:39:45.238+05:30</updated><category term="Sharepoint 2010"/><category term="C#"/><category term="CSharp"/><category term="Sharepoint Designer 2010"/><category term="Visual Studio 2010"/><category term="Sharepoint List"/><category term="JQuery"/><category term="Feature Event Receiver"/><category term="Javascript"/><category term="SQL Server 2008"/><category term="HTML"/><category term="SQL Server 2005"/><category term="XSL"/><category term="XSLTStyleSheet"/><category term="Asp.net"/><category term="Content Query Web Part"/><category term="JSON"/><category term="Stored Procedure"/><category term="Visual Web Part"/><category term="Web Part"/><category term="CQWP"/><category term="CSS"/><category term="Content Type"/><category term="Master Page"/><category term="PowerShell"/><category term="User Profile Manager"/><category term="Variation"/><category term="WebPart"/><category term="ADO.Net"/><category term="DataTable"/><category term="Feature Stapler"/><category term="Group By Clause"/><category term="IIS Application Pool"/><category term="ListViewWebPart"/><category term="Sharepoint Error"/><category term="WCF"/><category term="Web Service"/><category term="ASHX Handler"/><category term="CTE"/><category term="Common Table Expression"/><category term="Cookies"/><category term="Dismount-SPContentDatabase"/><category term="Document Library"/><category term="ECMA"/><category term="GetToolParts()"/><category term="Globalization"/><category term="IIS 6.0"/><category term="IWebPartRow"/><category term="ItemStyle"/><category term="KnockOut.js"/><category term="List Template Look Up Field problem"/><category term="Listbox"/><category term="Localization"/><category term="LookUp field issue"/><category term="LookUp field not showing up"/><category term="MVC"/><category term="Module"/><category term="Mount-SPContentDatabase"/><category term="Multilingual Site"/><category term="My Content"/><category term="My Personal Site"/><category term="My Site"/><category term="NuGet"/><category term="Page Methods"/><category term="Paging"/><category term="PeopleEditor"/><category term="Publishing Image"/><category term="REST"/><category term="Resource File"/><category term="Set-SPCustomLayoutsPage"/><category term="SharePoint Group"/><category term="SharePoint Ribbon"/><category term="Target Audience"/><category term="URL Rewriting"/><category term="UpdatePanel"/><category term="User Information List"/><category term="User Profile Service"/><category term="Web Methods"/><category term="XML"/><category term="resx"/><title type='text'>Maulik Dhorajia</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>60</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-1499781837412596427</id><published>2016-03-17T01:54:00.000+05:30</published><updated>2016-03-17T01:54:46.928+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Service"/><title type='text'>WCF Services : System.ServiceModel(serviceBehaviors and bindings) settings for Http and Https.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
When a WCF service is converted from HTTP to HTTPS the service stops working. Here are the web.config settings. Which can fix the issue.
&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- SERVICE MODEL --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Behavior : Start --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpBehavior&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceMetadata&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceDebug&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Behavior : END --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Behavior : Start --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpsBehavior&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceMetadata&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;httpsGetEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;useRequestHeadersForMetadataAddress&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceDebug&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Behavior : END --&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;protocolMapping&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;basicHttpsBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;scheme&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpsBinding&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;protocolMapping&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceHostingEnvironment&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;aspNetCompatibilityEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;multipleSiteBindingsEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;
                               &lt;span class=&quot;attr&quot;&gt;minFreeMemoryPercentageToActivateService&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;5&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;bindings&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;basicHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Binding : Start --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;binding&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;allowCookies&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bypassProxyOnLocal&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;textEncoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;utf-8&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;messageEncoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Text&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxReceivedMessageSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxBufferSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;maxBufferPoolSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;readerQuotas&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxDepth&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxStringContentLength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxArrayLength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;
                        &lt;span class=&quot;attr&quot;&gt;maxBytesPerRead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxNameTableCharCount&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;None&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Binding : End --&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Binding : Start --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;binding&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpsBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;allowCookies&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bypassProxyOnLocal&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;textEncoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;utf-8&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;messageEncoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Text&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxReceivedMessageSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxBufferSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;
                 &lt;span class=&quot;attr&quot;&gt;maxBufferPoolSize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;readerQuotas&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxDepth&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxStringContentLength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxArrayLength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt;
                        &lt;span class=&quot;attr&quot;&gt;maxBytesPerRead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxNameTableCharCount&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2147483647&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Transport&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;transport&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;clientCredentialType&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;None&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;security&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Binding : End --&amp;gt;&lt;/span&gt;

      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;basicHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;bindings&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

      &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Service : Start --&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Sample.Service.HttpService&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;basicHttpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bindingName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bindingConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpBinding&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;contract&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Sample.Service.Interface.IHttpService&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTP :  Service : End --&amp;gt;&lt;/span&gt;

      &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Service : Start --&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Sample.Service.HttpsService&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;basicHttpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bindingName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bindingConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;httpsBinding&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;contract&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Sample.Service.Interface.IHttpsService&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- HTTPS :  Service : End --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- SERVICE MODEL --&amp;gt;&lt;/span&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/1499781837412596427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2016/03/wcf-services-systemservicemodelserviceb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/1499781837412596427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/1499781837412596427'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2016/03/wcf-services-systemservicemodelserviceb.html' title='WCF Services : System.ServiceModel(serviceBehaviors and bindings) settings for Http and Https.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-72114960204191398</id><published>2014-08-13T01:40:00.002+05:30</published><updated>2014-08-13T01:48:06.341+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASHX Handler"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="KnockOut.js"/><category scheme="http://www.blogger.com/atom/ns#" term="NuGet"/><title type='text'>[KnockOut.js]Sample code to for beginners.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
The blog is to create a working form using KnockOut.js, generic handler(ashx) and JQuery. This is strictly for beginners, who want to use KnockOut.js. I am not giving any solution in this blog, this is just a starting thread for the people who are still having trouble using KnockOut. 
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Steps&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create a visual studio project. I have named the solution as Sample and project name is Sample.KnockOut.&lt;/li&gt;
&lt;li&gt;Tools &gt; NuGet Package Manager &gt; Package Manager Console &gt; Run &quot;Install-Package knockoutjs&quot; (&lt;a 
href=&quot;https://www.nuget.org/packages/knockoutjs&quot; target=&quot;_blank&quot;&gt;CLICK HERE&lt;/a&gt;)&lt;/li&gt;

&lt;li&gt;Tools &gt; NuGet Package Manager &gt; Package Manager Console &gt; Run &quot;Install-Package jQuery&quot; (&lt;a href=&quot;https://www.nuget.org/packages/jquery&quot; target=&quot;_blank&quot;&gt;CLICK HERE&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Add the files which are shown in the Solution Explorer image below and use the code which is mentioned in the blog. &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxNTcWoXicfdnxMXFFlL3CMhIhMfKFs2l3Q_3lNzKwZzyxj70khUQyXiE2XNS_SWjsVM09YA7q2hkmjj-Eg27DKJPn_aSLKmg_K197WHXG5g7jIgSOSatB7TZZQuReoL2hXTRZ5xmWA/s1600/Pic2.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxNTcWoXicfdnxMXFFlL3CMhIhMfKFs2l3Q_3lNzKwZzyxj70khUQyXiE2XNS_SWjsVM09YA7q2hkmjj-Eg27DKJPn_aSLKmg_K197WHXG5g7jIgSOSatB7TZZQuReoL2hXTRZ5xmWA/s320/Pic2.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;OrderHandler.ashx.cs&lt;/h3&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.Script.Serialization;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.SessionState;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Sample.KnockOut.Ajax
{
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// OrderHandler.ashx - Just processes data coming from default.aspx.&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; OrderHandler : IHttpHandler, IRequiresSessionState
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Properties

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Is Reusable&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; IsReusable
        {
            &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
            }
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Http Context&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; HttpContext Context { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Sample Entity List&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; IList&amp;lt;Entity.Order&amp;gt; OrderList
        {
            &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (Context.Session[&lt;span class=&quot;str&quot;&gt;&quot;OrderList&quot;&lt;/span&gt;] == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    Context.Session[&lt;span class=&quot;str&quot;&gt;&quot;OrderList&quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;Entity.Order&amp;gt;();
                }
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; (List&amp;lt;Entity.Order&amp;gt;)Context.Session[&lt;span class=&quot;str&quot;&gt;&quot;OrderList&quot;&lt;/span&gt;];
            }
            &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt; { Context.Session[&lt;span class=&quot;str&quot;&gt;&quot;OrderList&quot;&lt;/span&gt;] = value; }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Process Request

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Process Request&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;context&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ProcessRequest(HttpContext context)
        {
            &lt;span class=&quot;rem&quot;&gt;// Set the context &lt;/span&gt;
            Context = context;

            &lt;span class=&quot;rem&quot;&gt;// Action which is passed to get the &lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; action = (context.Request[&lt;span class=&quot;str&quot;&gt;&quot;Process&quot;&lt;/span&gt;] ?? &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty);

            &lt;span class=&quot;rem&quot;&gt;// Check for action and settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (action)
            {
                &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;GetOrder&quot;&lt;/span&gt;:
                    {
                        GetOrder();
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;AddUpdateItem&quot;&lt;/span&gt;:
                    {
                        AddUpdateItem();
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;DeleteOrder&quot;&lt;/span&gt;:
                    {
                        DeleteItem();
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;GetList&quot;&lt;/span&gt;:
                &lt;span class=&quot;kwrd&quot;&gt;default&lt;/span&gt;:
                    {
                        GetList();
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Actions

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Get List : Gets the list of &lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetList()
        {
            &lt;span class=&quot;rem&quot;&gt;// Sample Entity List&lt;/span&gt;
            OrderList = OrderList.OrderBy(a =&amp;gt; a.OrderId).ToList();

            &lt;span class=&quot;rem&quot;&gt;// Response the settings&lt;/span&gt;
            Context.Response.ContentType = &lt;span class=&quot;str&quot;&gt;&quot;application/json&quot;&lt;/span&gt;;
            Context.Response.ContentEncoding = Encoding.UTF8;
            Context.Response.Write(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer().Serialize(OrderList));
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Get Order By Order Id&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetOrder()
        {
            &lt;span class=&quot;rem&quot;&gt;// Remove the item&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; orderId = Convert.ToInt32(Context.Request.Params[&lt;span class=&quot;str&quot;&gt;&quot;OrderId&quot;&lt;/span&gt;] ?? &lt;span class=&quot;str&quot;&gt;&quot;0&quot;&lt;/span&gt;);

            &lt;span class=&quot;rem&quot;&gt;// Sample Entity List&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; order = OrderList.FirstOrDefault(a =&amp;gt; a.OrderId == orderId);

            &lt;span class=&quot;rem&quot;&gt;// Response the settings&lt;/span&gt;
            Context.Response.ContentType = &lt;span class=&quot;str&quot;&gt;&quot;application/json&quot;&lt;/span&gt;;
            Context.Response.ContentEncoding = Encoding.UTF8;
            Context.Response.Write(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer().Serialize(order));
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Add/Update Item&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; AddUpdateItem()
        {
            &lt;span class=&quot;rem&quot;&gt;// Get the request&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; request = (&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer()).Deserialize&amp;lt;Entity.Order&amp;gt;(Context.Request.Params[&lt;span class=&quot;str&quot;&gt;&quot;Request&quot;&lt;/span&gt;]);

            &lt;span class=&quot;rem&quot;&gt;// Add Item&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (request.OrderId == 0) 
            {
                &lt;span class=&quot;rem&quot;&gt;// Get the max id&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; maxId = (OrderList.Any() ? OrderList.Max(a =&amp;gt; a.OrderId) : 0);
                request.OrderId = maxId + 1;

                &lt;span class=&quot;rem&quot;&gt;// Add to the session&lt;/span&gt;
                OrderList.Add(request);
            }
            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;rem&quot;&gt;// Update Item&lt;/span&gt;
            {
                &lt;span class=&quot;rem&quot;&gt;// remove the item&lt;/span&gt;
                OrderList = OrderList.Where(a =&amp;gt; a.OrderId != request.OrderId).ToList();

                &lt;span class=&quot;rem&quot;&gt;// Add to the session&lt;/span&gt;
                OrderList.Add(request);
            }

            &lt;span class=&quot;rem&quot;&gt;// Returns the list&lt;/span&gt;
            GetList();
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Delete Item&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; DeleteItem()
        {
            &lt;span class=&quot;rem&quot;&gt;// Remove the item&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; orderId = Convert.ToInt32(Context.Request.Params[&lt;span class=&quot;str&quot;&gt;&quot;OrderId&quot;&lt;/span&gt;] ?? &lt;span class=&quot;str&quot;&gt;&quot;0&quot;&lt;/span&gt;);

            &lt;span class=&quot;rem&quot;&gt;// remove the item&lt;/span&gt;
            OrderList = OrderList.Where(a =&amp;gt; a.OrderId != orderId).ToList();

            &lt;span class=&quot;rem&quot;&gt;// Returns the list&lt;/span&gt;
            GetList();
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Style.css&lt;/h3&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
* { font-family: verdana; }
div{padding: 2px;}
input{ border: 1px solid #808080;}

.div-main { width: 600px; }
.div-sub-row { width: 600px; }
.div-left-box { width: 150px;text-align: right;float: left;}
.div-right-box { width: 395px;text-align: left;float: left;padding-left: 5px;}
.div-clear { clear: both; }

.div-order-counter{border: 1px solid #efefef;padding:5px;background: red;color: #fff;}

.div-main-grid{ width: 600px;font-size: 11px; }

.div-main-grid-column1{ float: left;text-align: center;width: 50px; }
.div-main-grid-column2{ float: left;text-align: center;width: 150px; }
.div-main-grid-column3{ float: left;text-align: center;width: 250px; }
.div-main-grid-column4{ float: left;text-align: center;width: 50px; }
.div-main-grid-column5{ float: left;text-align: center;width: 50px; }

.div-main-grid-header{ background: #1e90ff;color:#ffffff;height: 25px; }
.div-main-grid-item{ background: #efefef;color:#000;height: 25px; }
.div-main-grid-alternating-item{ background: #fff;color:#000;height: 25px; }&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Entity.cs&lt;/h3&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Sample.KnockOut.Entity
{
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Order&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [Serializable]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Order
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; OrderId { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; OrderName { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; IList&amp;lt;OrderItem&amp;gt; OrderItems { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    }

    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Order Items&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [Serializable]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; OrderItem
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; Quantity { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ItemName { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    }
}&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Sample.js&lt;/h3&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;/*&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;    Author : Maulik Dhorajia&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;    Description : Sample to show KnockOut.js usage. This will be helpful for beginners only.&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;*/&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;// Default settings for KnockOut.js&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (location.protocol != &lt;span class=&quot;str&quot;&gt;&quot;data:&quot;&lt;/span&gt;) {
    $(window).bind(&lt;span class=&quot;str&quot;&gt;&#39;hashchange&#39;&lt;/span&gt;, function () {
        window.parent.handleChildIframeUrlChange(location.hash);
    });
}

&lt;span class=&quot;rem&quot;&gt;// GLOBAL DECLARATIONS&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; viewModel;

&lt;span class=&quot;rem&quot;&gt;// Page Load&lt;/span&gt;
$(document).ready(function () {
    &lt;span class=&quot;rem&quot;&gt;// Apply Binding - Which can help in applying binding.&lt;/span&gt;
    ApplyBindingHandlers();
    &lt;span class=&quot;rem&quot;&gt;// Apply exterders&lt;/span&gt;
    ApplyNumericExtender();
    &lt;span class=&quot;rem&quot;&gt;// Populate View Model&lt;/span&gt;
    PopulateViewModel();
});

&lt;span class=&quot;rem&quot;&gt;// Apply Binding Handlers&lt;/span&gt;
function ApplyBindingHandlers() {
    ko.bindingHandlers.integerBoxSettings = {
        init: function (element, valueAccessor) {

            &lt;span class=&quot;rem&quot;&gt;// Define the settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; $element = $(element);
            
            &lt;span class=&quot;rem&quot;&gt;// Bind change event&lt;/span&gt;
            $element.blur(function () {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (parseInt($(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).val()) &amp;gt; 0) {
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;border&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;1px solid green&quot;&lt;/span&gt;);
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;color&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;green&quot;&lt;/span&gt;);
                }
                &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (parseInt($(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).val()) &amp;lt; 0) {
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;border&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;1px solid red&quot;&lt;/span&gt;);
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;color&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;red&quot;&lt;/span&gt;);
                }
                &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (parseInt($(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).val()) == 0) {
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;border&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;1px solid #808080&quot;&lt;/span&gt;);
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;color&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;black&quot;&lt;/span&gt;);
                }
            });
            
            $element.focus(function () {
                $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;border&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;1px solid #808080&quot;&lt;/span&gt;);
                $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).css(&lt;span class=&quot;str&quot;&gt;&quot;color&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;black&quot;&lt;/span&gt;);
            });
        }
    };
    
    &lt;span class=&quot;rem&quot;&gt;// combine Items And Display - This will bind the items in the gird&lt;/span&gt;
    ko.bindingHandlers.combineItemsAndDisplay = {
        init: function (element, valueAccessor) {

            &lt;span class=&quot;rem&quot;&gt;// Define the settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; $element = $(element);
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; value = ko.utils.unwrapObservable(valueAccessor());

            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (value != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; value.OrderItems.length &amp;gt; 0) {
                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; html = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; value.OrderItems.length; i++) {
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!(value.OrderItems[i].Quantity &amp;lt;= 0 || value.OrderItems[i].ItemName == &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;)) {
                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (html != &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;) {
                            html += &lt;span class=&quot;str&quot;&gt;&quot;, &quot;&lt;/span&gt;;
                        }
                        html += value.OrderItems[i].Quantity.toString() + &lt;span class=&quot;str&quot;&gt;&quot; - &quot;&lt;/span&gt; + value.OrderItems[i].ItemName;
                    }
                }
                $element.html(html);
            }
        }
    };
    
    &lt;span class=&quot;rem&quot;&gt;// Edit Item Settings&lt;/span&gt;
    ko.bindingHandlers.editItemSettings = {
        init: function (element, valueAccessor) {

            &lt;span class=&quot;rem&quot;&gt;// Define the settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; $element = $(element);
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; value = ko.utils.unwrapObservable(valueAccessor());
            
            $element.click(function () {
                CallHandler(&lt;span class=&quot;str&quot;&gt;&quot;GetOrder&quot;&lt;/span&gt;, value.OrderId.toString());
            });
        }
    };
    
    &lt;span class=&quot;rem&quot;&gt;// Delete Item Settings&lt;/span&gt;
    ko.bindingHandlers.deleteItemSettings = {
        init: function (element, valueAccessor) {

            &lt;span class=&quot;rem&quot;&gt;// Define the settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; $element = $(element);
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; value = ko.utils.unwrapObservable(valueAccessor());
            
            $element.click(function () {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (confirm(&lt;span class=&quot;str&quot;&gt;&quot;Are you sure you want to delete the record?&quot;&lt;/span&gt;)) {
                    CallHandler(&lt;span class=&quot;str&quot;&gt;&quot;DeleteOrder&quot;&lt;/span&gt;, value.OrderId.toString());
                }
            });
        }
    };
}

&lt;span class=&quot;rem&quot;&gt;// Applies the extenders&lt;/span&gt;
function ApplyNumericExtender() {

    &lt;span class=&quot;rem&quot;&gt;// Validate numbers only&lt;/span&gt;
    ko.extenders.numeric = function (target, precision) {
        &lt;span class=&quot;rem&quot;&gt;// create a writeable computed observable to intercept writes to our observable&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; result = ko.computed({
            read: target,  &lt;span class=&quot;rem&quot;&gt;// always return the original observables value&lt;/span&gt;
            write: function (newValue) {
                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; current = target(),
                    roundingMultiplier = Math.pow(10, precision),
                    newValueAsNum = isNaN(newValue) ? 0 : parseFloat(+newValue),
                    valueToWrite = Math.round(newValueAsNum * roundingMultiplier) / roundingMultiplier;

                &lt;span class=&quot;rem&quot;&gt;// only write if it changed&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (valueToWrite !== current) {
                    target(valueToWrite);
                } &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; {
                    &lt;span class=&quot;rem&quot;&gt;// if the rounded value is the same, but a different value was written, force a notification for the current field&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (newValue !== current) {
                        target.notifySubscribers(valueToWrite);
                    }
                }
            }
        });

        &lt;span class=&quot;rem&quot;&gt;// initialize with current value to make sure it is rounded appropriately&lt;/span&gt;
        result(target());

        &lt;span class=&quot;rem&quot;&gt;// return the new computed observable&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; result;
    };
}

&lt;span class=&quot;rem&quot;&gt;// OrderItem : Object&lt;/span&gt;
function OrderItem(quantity, itemName) {
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; self = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;;
    self.Quantity = ko.observable(quantity).extend({ numeric: 0 }); &lt;span class=&quot;rem&quot;&gt;// Extended to check if Quantity is string it will replace it with 0.&lt;/span&gt;
    self.ItemName = ko.observable(itemName);
}

&lt;span class=&quot;rem&quot;&gt;// Order View Model&lt;/span&gt;
function OrderViewModel() {
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; self = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;;
    self.OrderId = ko.observable(0);
    self.OrderName = ko.observable(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);
    self.OrderItemList = ko.observableArray([&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OrderItem(0, &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;), &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OrderItem(0, &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;), &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OrderItem(0, &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;)]);

    &lt;span class=&quot;rem&quot;&gt;// This will be the result from json call&lt;/span&gt;
    self.OrderList = ko.observableArray([]);
    
    &lt;span class=&quot;rem&quot;&gt;// Events&lt;/span&gt;
    self.SaveClick = function () {
        &lt;span class=&quot;rem&quot;&gt;// Validation&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (viewModel.OrderName() == &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;) {
            alert(&lt;span class=&quot;str&quot;&gt;&quot;Order name is required.&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;
        }

        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; orderItems = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Array();
        &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; viewModel.OrderItemList().length; i++) {
            orderItems.push({ Quantity: viewModel.OrderItemList()[i].Quantity(), ItemName: viewModel.OrderItemList()[i].ItemName() });
        }
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; request = { &lt;span class=&quot;str&quot;&gt;&quot;OrderId&quot;&lt;/span&gt;: viewModel.OrderId(), &lt;span class=&quot;str&quot;&gt;&quot;OrderName&quot;&lt;/span&gt;: viewModel.OrderName(), &lt;span class=&quot;str&quot;&gt;&quot;OrderItems&quot;&lt;/span&gt;: orderItems };
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; postData = { Request: JSON.stringify(request) };
        CallHandler(&lt;span class=&quot;str&quot;&gt;&quot;AddUpdateItem&quot;&lt;/span&gt;, postData);
    };
    
    self.ClearClick = function () {
        ClearScreen();
    };
}

&lt;span class=&quot;rem&quot;&gt;// Populates view model&lt;/span&gt;
function PopulateViewModel() {
    CallHandler(&lt;span class=&quot;str&quot;&gt;&quot;GetList&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;);
}

&lt;span class=&quot;rem&quot;&gt;// Call Handler&lt;/span&gt;
function CallHandler(callMethod, postData) {
    &lt;span class=&quot;rem&quot;&gt;//Supports cors&lt;/span&gt;
    $.ajaxSetup({ cache: &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt; });
    $.support.cors = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (callMethod == &lt;span class=&quot;str&quot;&gt;&quot;GetOrder&quot;&lt;/span&gt; || callMethod == &lt;span class=&quot;str&quot;&gt;&quot;DeleteOrder&quot;&lt;/span&gt;) {
        postData = { OrderId: postData };
    }
    &lt;span class=&quot;rem&quot;&gt;// Cart Proxy&lt;/span&gt;
    $.post(&lt;span class=&quot;str&quot;&gt;&quot;Ajax/OrderHandler.ashx?Process=&quot;&lt;/span&gt; + callMethod.toString(), postData, function (response) {
        SuccessOnServiceCall(response, callMethod);
    }).fail(function (jqXhr, textStatus, errorThrown) {
        ErrorOnServiceCall(jqXhr, textStatus, errorThrown);
    });
}

&lt;span class=&quot;rem&quot;&gt;// Bind the screen&lt;/span&gt;
function SuccessOnServiceCall(response, callMethod) {
    &lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (callMethod) {
    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;GetList&quot;&lt;/span&gt;:
        {
            &lt;span class=&quot;rem&quot;&gt;// DO nothing&lt;/span&gt;
        } &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;GetOrder&quot;&lt;/span&gt;:
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (response != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;) {
                    viewModel.OrderId(response.OrderId);
                    viewModel.OrderName(response.OrderName);
                    
                    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; response.OrderItems.length; i++) {
                        viewModel.OrderItemList()[i].Quantity(response.OrderItems[i].Quantity);
                        viewModel.OrderItemList()[i].ItemName(response.OrderItems[i].ItemName);
                    }
                }
            } &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;AddUpdateItem&quot;&lt;/span&gt;:
        {
            ClearScreen();
            alert(&lt;span class=&quot;str&quot;&gt;&quot;Order saved successfully.&quot;&lt;/span&gt;);
        } &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;DeleteItem&quot;&lt;/span&gt;:
        {
            ClearScreen();
            alert(&lt;span class=&quot;str&quot;&gt;&quot;Order deleted successfully.&quot;&lt;/span&gt;);
        } &lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
    }
    
    &lt;span class=&quot;rem&quot;&gt;// Apply the model if null&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (viewModel == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;) {
        &lt;span class=&quot;rem&quot;&gt;// Apply the View Model&lt;/span&gt;
        viewModel = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OrderViewModel();
        RefreshOrderList(response);
        &lt;span class=&quot;rem&quot;&gt;// This should be called only once.&lt;/span&gt;
        ko.applyBindings(viewModel, document.getElementById(&lt;span class=&quot;str&quot;&gt;&quot;knockout-main-form&quot;&lt;/span&gt;)); &lt;span class=&quot;rem&quot;&gt;// document.getElementById =&amp;gt; Should be the like this. Whatever controls are there in this element can only be use the script.   &lt;/span&gt;
    } &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (callMethod != &lt;span class=&quot;str&quot;&gt;&quot;GetOrder&quot;&lt;/span&gt;) {
            RefreshOrderList(response);
        }
    }
}

&lt;span class=&quot;rem&quot;&gt;// Display on error message&lt;/span&gt;
function ErrorOnServiceCall(jqXhr, textStatus, errorThrown) {
    alert(JSON.stringify(jqXhr));
}

&lt;span class=&quot;rem&quot;&gt;// Refresh Order List : VERY IMPORTANT DONT BIND THE WHOLE OBJECT IT WONT WORK :)&lt;/span&gt;
function RefreshOrderList(orders) {
    viewModel.OrderList([]);
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (orders != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; orders.length &amp;gt; 0) {
        &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; orders.length; i++) {
            viewModel.OrderList.push(ko.observable(orders[i]));
        }
    }
}

&lt;span class=&quot;rem&quot;&gt;// Clear screen&lt;/span&gt;
function ClearScreen() {
    viewModel.OrderId(0);
    viewModel.OrderName(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);
    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; viewModel.OrderItemList().length; i++) {
        viewModel.OrderItemList()[i].Quantity(0);
        viewModel.OrderItemList()[i].ItemName(&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;);
    }
}&lt;/pre&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;h3&gt;Default.aspx&lt;/h3&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;asp&quot;&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Default.aspx.cs&quot; Inherits=&quot;Sample.KnockOut.Default&quot; %&amp;gt;&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- Title --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;KnockOut.js - Sample&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- Script --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Scripts/jquery-2.1.1.js&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &amp;lt;script type=&lt;span class=&quot;str&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; src=&lt;span class=&quot;str&quot;&gt;&quot;Scripts/knockout-3.1.0.js&quot;&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type=&lt;span class=&quot;str&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; src=&lt;span class=&quot;str&quot;&gt;&quot;Scripts/Sample.js&quot;&lt;/span&gt;&amp;gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;&amp;lt;!-- Css --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;link&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Css/Style.css&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;knockout-main-form&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;KnockOut.js - Sample for observable object by KnockOut.js.&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;divMain&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-sub-row&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-left-box&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Order name :&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-right-box&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;value: OrderName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxlength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;15&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: OrderId, visible: false&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-clear&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-sub-row&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Quantity&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Item Name&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;thead&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;foreach: OrderItemList&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;value: Quantity, integerBoxSettings: $data&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxlength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;width: 100px&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;value: ItemName&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;maxlength&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;15&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;width: 250px&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tbody&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-clear&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;button&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Save&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;click: SaveClick&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;attr&quot;&gt;&amp;amp;nbsp;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;button&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Clear&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;click: ClearClick&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-order-counter&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: &#39;There are &#39;+ OrderList().length +&#39; order(s) in memory.&#39;&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;=&quot;&lt;span class=&quot;attr&quot;&gt;visible:&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OrderList&lt;/span&gt;().&lt;span class=&quot;attr&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; 0&quot; class=&quot;div-main-grid&quot;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-header&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column1&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Id&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column2&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Name&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column3&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Items&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column4&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Edit&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column5&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Delete&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;=&quot;&lt;span class=&quot;attr&quot;&gt;visible:&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;OrderList&lt;/span&gt;().&lt;span class=&quot;attr&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; 0, foreach: OrderList&quot; class=&quot;div-main-grid&quot;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;css: (($index() + 1) % 2 == 0 ? &#39;div-main-grid-alternating-item&#39; : &#39;div-main-grid-item&#39; )&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: OrderId&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: OrderName&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column3&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;combineItemsAndDisplay: $data&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column4&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:void(0);&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: &#39;Edit&#39;, editItemSettings: $data&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;div-main-grid-column5&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:void(0);&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;data-bind&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text: &#39;Delete&#39;, deleteItemSettings: $data&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Final Out Come&lt;/h3&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaMCPHtachzD-w3djuXXqn-Coc-sNT4qkz2HjUT5OR5VPZFqV81L8GQgAkg2_p6BKS_hELLjLABjcAYkyN8LnW83YBrXrcNrRM7iHbQFm3pHihypzOxvWwKDhyeWm-WlagwhesSx6BnQ/s1600/Pic1.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaMCPHtachzD-w3djuXXqn-Coc-sNT4qkz2HjUT5OR5VPZFqV81L8GQgAkg2_p6BKS_hELLjLABjcAYkyN8LnW83YBrXrcNrRM7iHbQFm3pHihypzOxvWwKDhyeWm-WlagwhesSx6BnQ/s320/Pic1.png&quot; /&gt;&lt;/a&gt;

&lt;br /&gt;&lt;br /&gt;
Please let me know if this helped or not.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/72114960204191398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2014/08/knockoutjssample-code-to-for-beginners.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/72114960204191398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/72114960204191398'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2014/08/knockoutjssample-code-to-for-beginners.html' title='[KnockOut.js]Sample code to for beginners.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxNTcWoXicfdnxMXFFlL3CMhIhMfKFs2l3Q_3lNzKwZzyxj70khUQyXiE2XNS_SWjsVM09YA7q2hkmjj-Eg27DKJPn_aSLKmg_K197WHXG5g7jIgSOSatB7TZZQuReoL2hXTRZ5xmWA/s72-c/Pic2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-2869426188624657635</id><published>2014-07-26T01:10:00.000+05:30</published><updated>2014-07-26T01:10:38.699+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="IIS Application Pool"/><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><title type='text'>Create virtual directories and application pools using PowerShell scripts</title><content type='html'>&lt;h3&gt;Purpose&lt;/h3&gt;
This script will create an application pool if its does not exists and a virtual directory for the site using PowerShell.&lt;br /&gt;
&lt;h3&gt;Scenario&lt;/h3&gt;
Suppose we have a website(in this case we have test.maulikdhorajia.com). And we have to create 100 virtual directories in the same website with same structure. But some Virtual Directories are already there and some needs to be created. Some of them uses framework 2.0 and some 4.0. Some of them are having 32 bit enabled and some of them don&#39;t need it. Using this script we can do it with saving a lot of time in doing manual process.
&lt;br /&gt;&lt;br /&gt;

&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;### Author : Maulik Dhorajia&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;### Purpose : This script will create an application pool if its doesnot exists and will create a virtual directory for the site using PowerShell.&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;# IMPORT WebAdministration Module&lt;/span&gt;
Import-Module WebAdministration

&lt;span class=&quot;rem&quot;&gt;# Current Folder Declarations&lt;/span&gt;
$currentFolder = Split-Path -parent $MyInvocation.MyCommand.Definition
write-host &lt;span class=&quot;str&quot;&gt;&quot;Folder name : &quot;&lt;/span&gt; $currentFolder

&lt;span class=&quot;rem&quot;&gt;# Create a virtual directory and application pool using PowerShell.&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; CreateAppPoolAndVirtualDirectory( $iisAppPoolName, $iisAppPoolDotNetVersion , $iisAppName, $enable32Bit)
{
    &lt;span class=&quot;rem&quot;&gt;# Set up the directory path&lt;/span&gt;
    $directoryPath = &lt;span class=&quot;str&quot;&gt;&quot;$currentFolder\$iisAppName&quot;&lt;/span&gt;
    Write-Host &lt;span class=&quot;str&quot;&gt;&quot;Path: $directoryPath&quot;&lt;/span&gt;
    
    &lt;span class=&quot;rem&quot;&gt;# Validation&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(($iisAppPoolName &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; $null) -or ($iisAppPoolName &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;))
    {
        Write-Host &lt;span class=&quot;str&quot;&gt;&quot;AppPool name is required.&quot;&lt;/span&gt; -foregroundcolor &lt;span class=&quot;str&quot;&gt;&quot;Red&quot;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;
    }
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(($iisAppName &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; $null) -or ($iisAppName &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;))
    {
        Write-Host &lt;span class=&quot;str&quot;&gt;&quot;Application name is required.&quot;&lt;/span&gt; -foregroundcolor &lt;span class=&quot;str&quot;&gt;&quot;Red&quot;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;
    }
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(($directoryPath &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; $null) -or ($directoryPath &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;))
    {
        Write-Host &lt;span class=&quot;str&quot;&gt;&quot;Directory path is required.&quot;&lt;/span&gt; -foregroundcolor &lt;span class=&quot;str&quot;&gt;&quot;Red&quot;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;
    }
    
    &lt;span class=&quot;rem&quot;&gt;# Conditional Missing Records&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(($iisAppPoolDotNetVersion &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; $null) -or ($iisAppPoolDotNetVersion &lt;span class=&quot;preproc&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;))
    {
        $iisAppPoolDotNetVersion = &lt;span class=&quot;str&quot;&gt;&quot;v4.0&quot;&lt;/span&gt;
    }
    
    &lt;span class=&quot;rem&quot;&gt;# Navigate to the app pools root&lt;/span&gt;
    cd IIS:\AppPools\

    &lt;span class=&quot;rem&quot;&gt;# Check if the app pool exists&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!(Test-Path $iisAppPoolName -pathType container))
    {
        &lt;span class=&quot;rem&quot;&gt;#create the app pool&lt;/span&gt;
        $appPool = New-Item $iisAppPoolName
        &lt;span class=&quot;rem&quot;&gt;# Assign App Pool Version&lt;/span&gt;
        $appPool | Set-ItemProperty -Name &lt;span class=&quot;str&quot;&gt;&quot;managedRuntimeVersion&quot;&lt;/span&gt; -Value $iisAppPoolDotNetVersion
        &lt;span class=&quot;rem&quot;&gt;# Enable 32-Bit &quot;True&quot; or &quot;False&quot;&lt;/span&gt;
        $appPool | Set-ItemProperty -Name &lt;span class=&quot;str&quot;&gt;&quot;enable32BitAppOnWin64&quot;&lt;/span&gt; -Value $enable32Bit
        Write-Host &lt;span class=&quot;str&quot;&gt;&quot;$iisAppPoolName : Pool created successfully.&quot;&lt;/span&gt; -foregroundcolor &lt;span class=&quot;str&quot;&gt;&quot;green&quot;&lt;/span&gt;
    }

    &lt;span class=&quot;rem&quot;&gt;#navigate to the sites root&lt;/span&gt;
    cd IIS:\Sites\
        
    &lt;span class=&quot;rem&quot;&gt;# IIS Site&lt;/span&gt;
    $iissite = &lt;span class=&quot;str&quot;&gt;&quot;iis:\sites\test.maulikdhorajia.com\$iisAppName&quot;&lt;/span&gt;
    $subSite = Get-ChildItem &lt;span class=&quot;str&quot;&gt;&quot;iis:\sites\test.maulikdhorajia.com\&quot; | ? {$_.Name -eq $iisAppName -and $_.Type -eq &quot;&lt;/span&gt;application&lt;span class=&quot;str&quot;&gt;&quot;}
    
    if( $subSite -eq $null)
    {
        # Create the app
        $iisApp = New-Item $iissite -type Application -physicalPath $directoryPath
        Set-ItemProperty $iissite -Name &quot;&lt;/span&gt;applicationPool&lt;span class=&quot;str&quot;&gt;&quot; -Value $iisAppPoolName                
        Write-Host $iisAppName &quot;&lt;/span&gt; : Application created successfully.&lt;span class=&quot;str&quot;&gt;&quot; -foregroundcolor &quot;&lt;/span&gt;green&lt;span class=&quot;str&quot;&gt;&quot;
    }
    else
    {
        Write-Host $iisAppName &quot;&lt;/span&gt; : Application already exists!&lt;span class=&quot;str&quot;&gt;&quot; -foregroundcolor &quot;&lt;/span&gt;DarkMagenta&lt;span class=&quot;str&quot;&gt;&quot;
    }
}

# CREATE VIRTUAL DIRECTORY
CreateAppPoolAndVirtualDirectory &quot;&lt;/span&gt;Site1_AppPool&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;Site1&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;FALSE&lt;span class=&quot;str&quot;&gt;&quot;
CreateAppPoolAndVirtualDirectory &quot;&lt;/span&gt;Site2_AppPool&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;v4.0&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;Site2&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;FALSE&lt;span class=&quot;str&quot;&gt;&quot;
# USE FRAMEWORK 2.0
CreateAppPoolAndVirtualDirectory &quot;&lt;/span&gt;Site3_AppPool&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;v2.0&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;Site3&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;FALSE&lt;span class=&quot;str&quot;&gt;&quot;
# ENABLE 32 BIT ON APP POOL
CreateAppPoolAndVirtualDirectory &quot;&lt;/span&gt;Site4_AppPool&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;v4.0&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;Site4&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;TRUE&lt;span class=&quot;str&quot;&gt;&quot; 
# SAME APP POOL NAME
CreateAppPoolAndVirtualDirectory &quot;&lt;/span&gt;Site1_AppPool&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;v4.0&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;Site5&lt;span class=&quot;str&quot;&gt;&quot; &quot;&lt;/span&gt;FALSE&lt;span class=&quot;str&quot;&gt;&quot;

write-Host &quot;&lt;/span&gt;End of &lt;span class=&quot;kwrd&quot;&gt;script&lt;/span&gt;&quot;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/2869426188624657635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2014/07/create-virtual-directories-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/2869426188624657635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/2869426188624657635'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2014/07/create-virtual-directories-and.html' title='Create virtual directories and application pools using PowerShell scripts'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5465283468261535850</id><published>2014-05-29T19:56:00.000+05:30</published><updated>2014-05-29T19:56:49.096+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="IWebPartRow"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint List"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Part"/><title type='text'>Filter OOTB SharePoint ListView web part using IWebPartRow connection Interface and WebControl.</title><content type='html'>&lt;h3&gt;Related Blog&lt;/h3&gt;
In one of my old blogs I tried to explain the similar thing(&lt;a href=&quot;http://maulikdhorajia.blogspot.in/2012/09/filter-ootb-sharepoint-listview-web.html&quot;&gt;Filter OOTB SharePoint ListView web part using IWebPartRow connection Interface.&lt;/a&gt;). The purpose of that blog was just show a simple way of using the IWebPartRow connection and a ListView WebPart.
&lt;h3&gt;Goal&lt;/h3&gt;
In the current blog we will try and filter ListView WebPart using Connection object in IWebPartRow. Also there will be a RadioButtonList using which we can drill down the filter.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Create a custom list&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;Site Actions &gt; View All Site Content&lt;/li&gt;
&lt;li&gt;Create new List&lt;/li&gt;
&lt;li&gt;Custom List&lt;/li&gt;
&lt;li&gt;Name the list &quot;Sample&quot;.&lt;/li&gt; 
&lt;li&gt;Visit list settings and add new column &quot;Year&quot;.&lt;/li&gt;
&lt;li&gt;Add a few sample data.&lt;/li&gt;
&lt;li&gt;Alter the &quot;All Items&quot; and add ID in the view.&lt;/li&gt;
&lt;li&gt;Now the list will look like below given image.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiew4cyhKMX4pPa47YTqQB6lwGIckC2yG5uuGWgGfcxLhXWG6sM6SfHj8r-fXYZsCg-1C-9LeSDXMXjUhHEaGFS6gBX7TC8fJp8-Zfm2UXlAxeEnojHyAESigaCzy99B0d2TWbW5X-yXA/s1600/01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;152&quot; width=&quot;294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiew4cyhKMX4pPa47YTqQB6lwGIckC2yG5uuGWgGfcxLhXWG6sM6SfHj8r-fXYZsCg-1C-9LeSDXMXjUhHEaGFS6gBX7TC8fJp8-Zfm2UXlAxeEnojHyAESigaCzy99B0d2TWbW5X-yXA/s320/01.png&quot; /&gt;&lt;/a&gt;

&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;h3&gt;Web part for Conncetion&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;Open Visual Stuido 2010&lt;/li&gt;
&lt;li&gt;Create new project&lt;/li&gt;
&lt;li&gt;Select &quot;Web Part&quot;. Don&#39;t mistake using &quot;Visual Web Part&quot;.&lt;/li&gt;
&lt;li&gt;Rename the WebPart1 to &quot;SampleConnection&quot;.&lt;/li&gt;
&lt;li&gt;Use the below given code to be used as a sample.&lt;br /&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System

&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;

&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; SampleConnection.SampleConnection
{
    [ToolboxItemAttribute(&lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SampleConnection : WebPart, IWebPartRow
    {

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Properties

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Radiobutton&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; RadioButtonList RbtnYear { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Year&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; XYear
        {
            &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (System.Web.HttpContext.Current.Request.QueryString[&lt;span class=&quot;str&quot;&gt;&quot;XYear&quot;&lt;/span&gt;] == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; 0;
                }
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString[&lt;span class=&quot;str&quot;&gt;&quot;XYear&quot;&lt;/span&gt;]);
            }
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The Data table view for the Schema&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; DataTable XTable { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Constructor

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Creates the Schema of the table to get filtered column&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; SampleConnection()
        {
            RbtnYear = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; RadioButtonList();
            RbtnYear.Items.Insert(0, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ListItem(&lt;span class=&quot;str&quot;&gt;&quot;2004&quot;&lt;/span&gt;));
            RbtnYear.Items.Insert(1, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ListItem(&lt;span class=&quot;str&quot;&gt;&quot;2007&quot;&lt;/span&gt;));            
            RbtnYear.RepeatDirection = RepeatDirection.Horizontal;
            RbtnYear.AutoPostBack = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
            RbtnYear.SelectedIndexChanged += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; EventHandler(RbtnYear_SelectedIndexChanged);

            &lt;span class=&quot;rem&quot;&gt;//Create the object&lt;/span&gt;
            XTable = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTable();

            &lt;span class=&quot;rem&quot;&gt;//Adds the columns which we require for filteration&lt;/span&gt;
            DataColumn col = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataColumn();
            col.DataType = &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;);
            col.ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;;
            XTable.Columns.Add(col);

            &lt;span class=&quot;rem&quot;&gt;//Use the columns to be added to get the Values to be filtered&lt;/span&gt;
            DataRow row = XTable.NewRow();
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (XYear == 0)
            {
                row[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = Convert.ToInt32(RbtnYear.Items[0].Value);
            }
            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
            {
                row[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = XYear;            &lt;span class=&quot;rem&quot;&gt;// Year to be filtered                &lt;/span&gt;
            }
            XTable.Rows.Add(row);
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Events

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Radio Button Events&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; RbtnYear_SelectedIndexChanged(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            &lt;span class=&quot;rem&quot;&gt;//URL of the Page&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _url = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
            _url = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}?XYear={1}&quot;&lt;/span&gt;, _url, RbtnYear.SelectedValue);

            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (System.Web.HttpContext.Current.Request.QueryString.Count &amp;gt; 0)
            {
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; System.Web.HttpContext.Current.Request.QueryString.Count; i = i + 1)
                {
                    &lt;span class=&quot;rem&quot;&gt;//The xyear&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare(System.Web.HttpContext.Current.Request.QueryString.GetKey(i), &lt;span class=&quot;str&quot;&gt;&quot;XYear&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;) == 0)
                    {
                        &lt;span class=&quot;kwrd&quot;&gt;continue&lt;/span&gt;;
                    }

                    &lt;span class=&quot;rem&quot;&gt;//Recreate the URL&lt;/span&gt;
                    _url = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}&amp;amp;{1}={2}&quot;&lt;/span&gt;, _url, System.Web.HttpContext.Current.Request.QueryString.GetKey(i), System.Web.HttpContext.Current.Request.QueryString[i]);
                }
            }

            &lt;span class=&quot;rem&quot;&gt;//Send user back to page&lt;/span&gt;
            System.Web.HttpContext.Current.Response.Redirect(_url);
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Methods

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Override child controls&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; CreateChildControls()
        {
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.CreateChildControls();

            &lt;span class=&quot;rem&quot;&gt;//Add the radio button control&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Controls.Add(RbtnYear);
            RbtnYear.SelectedIndex = 0;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (XYear &amp;gt; 0)
            {
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (RbtnYear.Items.FindByValue(XYear.ToString()) != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    RbtnYear.SelectedValue = XYear.ToString();
                }
            }
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Connection provider and that assigns the Schema&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        [ConnectionProvider(&lt;span class=&quot;str&quot;&gt;&quot;Row&quot;&lt;/span&gt;)]
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; IWebPartRow GetConnectionInterface()
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SampleConnection();
        }


        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Implemented property &amp;amp; methods of IWebPartRow

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Gets data row view for ListView&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;callback&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; GetRowData(RowCallback callback)
        {
            callback(XTable.DefaultView[0]);
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Schema for the ListView web part&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; PropertyDescriptorCollection Schema
        {
            &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; TypeDescriptor.GetProperties(XTable.DefaultView[0]);
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;How to use?&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;SharePoint Site &gt; Edit a page.&lt;/li&gt;
&lt;li&gt;Click &quot;Add a Web Part&quot;.&lt;/li&gt;
&lt;li&gt;Top ribbon &gt; List and Libraries &gt; Select &quot;Sample&quot;.&lt;/li&gt;
&lt;li&gt;Again Click &quot;Add a Web Part&quot;.&lt;/li&gt;
&lt;li&gt;Top ribbon &gt; Custom &gt; Select &quot;SampleConnection&quot; web part.&lt;/li&gt;
&lt;li&gt;The screen will have now 2 Web Parts. Check out the below given image.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidSg6cXK1eorWZZgCzQQPAXwKsTK4OH-BXdGE5jzjvm8IIqBWOWYbRB7mzgICiTVUcmP7CMFlgYOIbE-JnOJdOFFpWIwL8Qz-7IPRfZB0660gGBuhJxSkJX5O20s5ssNHq28TSFcPb7g/s1600/02.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;152&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidSg6cXK1eorWZZgCzQQPAXwKsTK4OH-BXdGE5jzjvm8IIqBWOWYbRB7mzgICiTVUcmP7CMFlgYOIbE-JnOJdOFFpWIwL8Qz-7IPRfZB0660gGBuhJxSkJX5O20s5ssNHq28TSFcPb7g/s320/02.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;This happens in Edit Mode of page only, so make sure the page is in Edit Mode. Have a look at the image below to select a connection web part.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3f_9iT2f0_QiFBvGEqkCxTUf5sn68l8aYTvZGoNzusP7XpRBWemZYCAGaOkZKkBjsACxEWrmlMJHElAwuf2ohneAs2w_vcdiWXdFWZfZqFzXEiLy1ompdUccQui-mtgJPBCqhN4APw/s1600/03.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;201&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho3f_9iT2f0_QiFBvGEqkCxTUf5sn68l8aYTvZGoNzusP7XpRBWemZYCAGaOkZKkBjsACxEWrmlMJHElAwuf2ohneAs2w_vcdiWXdFWZfZqFzXEiLy1ompdUccQui-mtgJPBCqhN4APw/s320/03.png&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A box will popup to to select a filter. I will select Year. Click &quot;Finish&quot;.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMOm1IMwLQ8Gyc2e-Eb0zfk8bToSz6g9N5SgVA1_jHH43YEwbHRYgSMwnHcQ71gteTkzpvIkPSUZOpttQJHhVfrDErIDqvSTjYbBrI5wBdoOGHu48Xcyw0tZ-681ccp3RQ3P3iqc4Xmw/s1600/03.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;162&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMOm1IMwLQ8Gyc2e-Eb0zfk8bToSz6g9N5SgVA1_jHH43YEwbHRYgSMwnHcQ71gteTkzpvIkPSUZOpttQJHhVfrDErIDqvSTjYbBrI5wBdoOGHu48Xcyw0tZ-681ccp3RQ3P3iqc4Xmw/s320/03.png&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Now to test this stuff. Select the year from the Year from the &quot;Sample Connection&quot; web part.&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv24JKNQ1IvgJlbuoJVfGqaQUxE0kWT5Y7-2zHIhotpsED3-xvR_hZoprDdlouIx5Ta0ipnc9STlCeJH9HpRC5mTcdNr4nDdLLyREs95fF-C6q92Tnr8iv2HTA5y16mEQ-Te9ySX9ntA/s1600/04.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;138&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv24JKNQ1IvgJlbuoJVfGqaQUxE0kWT5Y7-2zHIhotpsED3-xvR_hZoprDdlouIx5Ta0ipnc9STlCeJH9HpRC5mTcdNr4nDdLLyREs95fF-C6q92Tnr8iv2HTA5y16mEQ-Te9ySX9ntA/s320/04.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZItJfcyCQwgLR-_UbTCCsUrq73GK-xu1E3mTPT_wbRu3hDyNkQyZDHyDNgsmq-dehRBVJkj8tktc-Lj2TI2ZoiAe1sS4XRenDMHdta1VaFnsLRIFYlWFAl5ehyAOmPXHhpWsZriMZNw/s1600/05.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;153&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZItJfcyCQwgLR-_UbTCCsUrq73GK-xu1E3mTPT_wbRu3hDyNkQyZDHyDNgsmq-dehRBVJkj8tktc-Lj2TI2ZoiAe1sS4XRenDMHdta1VaFnsLRIFYlWFAl5ehyAOmPXHhpWsZriMZNw/s320/05.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;So this was if a ListView needs filter. If we want to remove it. Just go through step 7 and click &quot;Remove Connection&quot; from the popup box. And the screen will be back to as it was.&lt;/li&gt;
&lt;/ol&gt;
&lt;bv /&gt;
Please let me know if this was helpful?</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5465283468261535850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/filter-ootb-sharepoint-listview-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5465283468261535850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5465283468261535850'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/filter-ootb-sharepoint-listview-web.html' title='Filter OOTB SharePoint ListView web part using IWebPartRow connection Interface and WebControl.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiew4cyhKMX4pPa47YTqQB6lwGIckC2yG5uuGWgGfcxLhXWG6sM6SfHj8r-fXYZsCg-1C-9LeSDXMXjUhHEaGFS6gBX7TC8fJp8-Zfm2UXlAxeEnojHyAESigaCzy99B0d2TWbW5X-yXA/s72-c/01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-3165908934235344557</id><published>2014-05-29T19:54:00.000+05:30</published><updated>2014-05-29T19:54:33.488+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Content Query Web Part"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Feature Stapler"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Designer 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint List"/><category scheme="http://www.blogger.com/atom/ns#" term="Variation"/><title type='text'>Sharepoint 2010 - Strange blog URL issue with site using Variations(Multilingual site). - REALLY WEIRD ISSUE!</title><content type='html'>&lt;h1&gt;Scenario/Symptoms&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;We have a site with variations. English/Spanish&lt;/li&gt;
&lt;li&gt;Structure&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Main Site &gt; en &gt; English Blog(Add 1 or 2 sample blogs)&lt;/li&gt;
&lt;li&gt;Main Site &gt; es &gt; Spanish Blog(Add 1 or 2 sample blogs)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;On the &quot;Main Site&quot; we added a &quot;&lt;a href=&quot;http://maulikdhorajia.blogspot.com/search/label/Content Query Web Part&quot;&gt;Content Query Web Part&lt;/a&gt;&quot;. Apply the below given setting. &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjgAhmjF7eQXUTM3H4pxfkLNGbODQNZt3_wxK4LfzIlqN0evYawZIs595SnfNcnSUD8RBPSR0Gh8qi9gJWJlmGNkHHwxd_6exXLhoH3wcQaJkUXPlNEMJDvjyvxq8tg53c5wWryyPiw/s1600/01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;274&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjgAhmjF7eQXUTM3H4pxfkLNGbODQNZt3_wxK4LfzIlqN0evYawZIs595SnfNcnSUD8RBPSR0Gh8qi9gJWJlmGNkHHwxd_6exXLhoH3wcQaJkUXPlNEMJDvjyvxq8tg53c5wWryyPiw/s320/01.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Click on the link of any English blog. &lt;b style=&#39;color:green;&#39;&gt;IT WORKS FINE!!!&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Now click on the Spanish blog link. &lt;b style=&#39;color:red;&#39;&gt;IT SAYS &quot;PAGE NOT FOUND&quot;!!!&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Another way to get this is. &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Go to the URL of Spanish blog site.&lt;/li&gt;
&lt;li&gt;You can find the blogs on the page.&lt;/li&gt;
&lt;li&gt;Click on the blog link &lt;b style=&#39;color:red;&#39;&gt;IT SAYS &quot;PAGE NOT FOUND&quot;!!!&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Or navigate to &quot;Administrar entradas de blog&quot;(AllPosts.aspx). This page will show all the blogs in the list. Click on the blog link &lt;b style=&#39;color:red;&#39;&gt;IT SAYS &quot;PAGE NOT FOUND&quot;!!!&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;
&lt;h1 style=&#39;color:red;&#39;&gt;Cause&lt;/h1&gt;We added a column to the list &quot;Post&quot;. Now this small thing was causing the whole havoc. &lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1 style=&#39;color:green;&#39;&gt;Solution&lt;/h1&gt;There are 3 ways to &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Either don&#39;t add any column to list &quot;Post&quot;. =&gt; BAD ONE&lt;/li&gt;
&lt;li&gt;Copy SharePoint Designer &gt; Lists &gt; Estrada De Blog and paste it there with name &quot;Post&quot;. Don&#39;t delete the folder. Just need to duplicate and rename the folder.&lt;/li&gt;
&lt;li&gt;Read the blog =&gt; &lt;a href=&quot;http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-solution-to-blog-url.html&quot;&gt;Sharepoint 2010 - Solution to blog URL issue with site using Variations(Multilingual site)&lt;/a&gt; to see the feature stapler solution for this issue. &lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;
Hope this helps. If you have any questions or a better solution, I am all open for it. Thanks for reading the blog.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/3165908934235344557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-strange-blog-url-issue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3165908934235344557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3165908934235344557'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-strange-blog-url-issue.html' title='Sharepoint 2010 - Strange blog URL issue with site using Variations(Multilingual site). - REALLY WEIRD ISSUE!'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOjgAhmjF7eQXUTM3H4pxfkLNGbODQNZt3_wxK4LfzIlqN0evYawZIs595SnfNcnSUD8RBPSR0Gh8qi9gJWJlmGNkHHwxd_6exXLhoH3wcQaJkUXPlNEMJDvjyvxq8tg53c5wWryyPiw/s72-c/01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-6836805344631934233</id><published>2014-05-29T19:53:00.000+05:30</published><updated>2014-05-29T19:53:20.827+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Feature Event Receiver"/><category scheme="http://www.blogger.com/atom/ns#" term="Feature Stapler"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint List"/><title type='text'>Sharepoint 2010 - Solution to blog URL issue with site using Variations(Multilingual site).</title><content type='html'>&lt;h1&gt;Issue&lt;/h1&gt;Read this blog -&gt; &lt;a href=&quot;http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-strange-blog-url-issue.html&quot; target=&quot;_blank&quot;&gt;Sharepoint 2010 - Strange blog URL issue with site using Variations(Multilingual site). - REALLY WEIRD ISSUE!&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;Solution&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;Create a Feature Stapler.&lt;/li&gt;
&lt;li&gt;Set the event scope as Scope=&quot;Site&quot; as the feature.&lt;/li&gt;
&lt;li&gt;Stapler &gt; Element.xml.&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xml&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;utf-8&quot;&lt;/span&gt;?&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Elements&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/sharepoint/&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;FeatureSiteTemplateAssociation&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;edf698b1-30db-4d19-b46b-5efbb5dae9a5&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;TemplateName&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Blog&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Elements&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Please use the below given code as a solution for the problem.&lt;/li&gt;
&lt;/ul&gt;&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Security.Permissions;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Utilities;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Administration;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.IO;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; FeatureStapler.VariationBlogSiteEvent
{
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Web Events&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; VariationBlogSiteEvent : SPWebEventReceiver
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Properties

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The site templates&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; EnmSiteTemplate
        {
            BLOG,    &lt;span class=&quot;rem&quot;&gt;//Blog Site&lt;/span&gt;
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// English Language&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; EnmLangugeCode
        {
            English = 1033
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Events

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// A site was provisioned.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; WebProvisioned(SPWebEventProperties properties)
        {
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.WebProvisioned(properties);

            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                SPSecurity.RunWithElevatedPrivileges(&lt;span class=&quot;kwrd&quot;&gt;delegate&lt;/span&gt;
                {
                    &lt;span class=&quot;rem&quot;&gt;//Create a web object&lt;/span&gt;
                    SPWeb _web = properties.Web;

                    &lt;span class=&quot;rem&quot;&gt;//Check and apply the settings&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_web.WebTemplate == EnmSiteTemplate.BLOG.ToString() &lt;span class=&quot;rem&quot;&gt;// If the site is a blog site&lt;/span&gt;
                        &amp;amp;&amp;amp; _web.Language != (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;)EnmLangugeCode.English) &lt;span class=&quot;rem&quot;&gt;// Language Selected is not english&lt;/span&gt;
                    {
                        &lt;span class=&quot;rem&quot;&gt;// Get the Library with correct folder&lt;/span&gt;
                        SPFolderCollection _folderInList = _web.Folders[&lt;span class=&quot;str&quot;&gt;&quot;Lists&quot;&lt;/span&gt;].SubFolders;

                        &lt;span class=&quot;rem&quot;&gt;//Find a folder with &quot;post.aspx&quot; &amp;amp; &quot;newpost.aspx&quot;&lt;/span&gt;
                        SPFolder _folderBlogNonEnglish = (from _folderX &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderInList.Cast&amp;lt;SPFolder&amp;gt;()
                                                          let _fName = _folderX.Name
                                                          let _fCount = (from _fileX &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderX.Files.Cast&amp;lt;SPFile&amp;gt;()
                                                                 &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare( _fileX.Name , &lt;span class=&quot;str&quot;&gt;&quot;post.aspx&quot;&lt;/span&gt; , &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt; ) == 0
                                                                select _fileX).Count()
                                                          &lt;span class=&quot;kwrd&quot;&gt;where&lt;/span&gt; _fCount &amp;gt; 0
                                                          select _folderX).FirstOrDefault();

                        &lt;span class=&quot;rem&quot;&gt;//So if any folder this properties exists&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_folderBlogNonEnglish != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                        {
                            &lt;span class=&quot;rem&quot;&gt;//The folder where file is going to come&lt;/span&gt;
                            SPFolder _folderBlogInEnglish = _folderBlogNonEnglish.ParentFolder.SubFolders.Add(&lt;span class=&quot;str&quot;&gt;&quot;Posts&quot;&lt;/span&gt;);
                            _folderBlogInEnglish.SubFolders.Add(&lt;span class=&quot;str&quot;&gt;&quot;Attachments&quot;&lt;/span&gt;);
                            _folderBlogInEnglish.SubFolders.Add(&lt;span class=&quot;str&quot;&gt;&quot;Post&quot;&lt;/span&gt;);

                            &lt;span class=&quot;rem&quot;&gt;//Copy the files to new folder&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (SPFile _file &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderBlogNonEnglish.Files)
                            {
                                _file.CopyTo(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}/{1}/{2}&quot;&lt;/span&gt;, _web.Url, _folderBlogInEnglish.Url, _file.Name), &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
                                &lt;span class=&quot;rem&quot;&gt;////Add a file&lt;/span&gt;
                                &lt;span class=&quot;rem&quot;&gt;//_folderBlogInEnglish.Files.Add(_file.Name, File.OpenRead(_file), true);&lt;/span&gt;

                                &lt;span class=&quot;rem&quot;&gt;// Commit &lt;/span&gt;
                                _folderBlogInEnglish.Update();
                            }
                        }                       
                    }

                });
            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (Exception Exc)
            {
                SPDiagnosticsService.Local.WriteTrace(0, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SPDiagnosticsCategory(&lt;span class=&quot;str&quot;&gt;&quot;VariationBlogSiteEvent&quot;&lt;/span&gt;, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, Exc.Message, Exc.StackTrace);
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

    }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
Hope this helps. If you have any questions or a better solution, I am all open for it. Thanks for reading the blog.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/6836805344631934233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-solution-to-blog-url.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6836805344631934233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6836805344631934233'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-solution-to-blog-url.html' title='Sharepoint 2010 - Solution to blog URL issue with site using Variations(Multilingual site).'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-7931299862652985721</id><published>2012-09-20T09:31:00.002+05:30</published><updated>2014-05-29T04:07:55.798+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Content Query Web Part"/><category scheme="http://www.blogger.com/atom/ns#" term="CQWP"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Globalization"/><category scheme="http://www.blogger.com/atom/ns#" term="Localization"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Variation"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Web Part"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Part"/><title type='text'>Override Content Query Webpart to do on the run filteration.</title><content type='html'>&lt;u&gt;&lt;b&gt;Problem&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;
In one of my recent project I had a challenge of filtering the data with localization. &lt;br /&gt;
The project contained 2 languages, English and Spanish. I was trying to find out the out of the box way to get this done, but no help was available. &lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Create a new empty project in Visual Studio 2010.&lt;/li&gt;
&lt;li&gt;Add a webpart to the project. &quot;&lt;b&gt;Webpart&lt;/b&gt;&quot; not &quot;&lt;b&gt;Visual Web Part&lt;/b&gt;&quot;.&lt;/li&gt;
&lt;li&gt;Replace the &lt;b&gt;Webpart&lt;/b&gt; class inherited and make it &quot;Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart&quot;.&lt;/li&gt;
&lt;li&gt;Please have a look at the code below. It will have on the fly list settings and field settings applied to the webpart.&lt;/li&gt;
&lt;li&gt;Build your code and deploy it. It should work.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Source Code&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;// Create the Toolbar&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; ToolBar.ToolBar
{
    [ToolboxItemAttribute(&lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ToolBar : Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Properties

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Root Site Name&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; SiteUrl { get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; SPContext.Current.Site.RootWeb.Url; } }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// List Name&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ListName { get { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;ToolBar&quot;&lt;/span&gt;; } }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// List of Url&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ListUrl
        {
            get
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}/Lists/{1}/AllItems.aspx&quot;&lt;/span&gt;, SiteUrl, ListName);
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Methods

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// On Page Load&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; OnInit(EventArgs e)
        {
            &lt;span class=&quot;rem&quot;&gt;//On Load&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.OnLoad(e);

            &lt;span class=&quot;rem&quot;&gt;//General Settings&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.AllowConnect = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ShowUntargetedItems = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.AllowEdit = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
            
            &lt;span class=&quot;rem&quot;&gt;//this.FrameType = &quot;NONE&quot;; // TODO&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ChromeType = PartChromeType.None;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ExportMode = WebPartExportMode.All;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GroupByDirection = SortDirection.Desc;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.SortByDirection = SortDirection.Desc;
            
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ConnectionID = System.Guid.Empty;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ListId = System.Guid.Empty;

            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ViewFlag = &lt;span class=&quot;str&quot;&gt;&quot;0&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GroupingText = &lt;span class=&quot;str&quot;&gt;&quot;GP Web Parts&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Title = &lt;span class=&quot;str&quot;&gt;&quot; Tool Bar&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ContentTypeName = &lt;span class=&quot;str&quot;&gt;&quot;Item&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ItemStyle = &lt;span class=&quot;str&quot;&gt;&quot;ToolBar&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ServerTemplate = &lt;span class=&quot;str&quot;&gt;&quot;100&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GroupStyle = &lt;span class=&quot;str&quot;&gt;&quot;DefaultHeader&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.WebUrl = &lt;span class=&quot;str&quot;&gt;&quot;~sitecollection&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Description = &lt;span class=&quot;str&quot;&gt;&quot;Displays a dynamic view of content from your site.&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Xsl = &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;xsl:stylesheet xmlns:x=\&quot;http://www.w3.org/2001/XMLSchema\&quot; version=\&quot;1.0\&quot; xmlns:xsl=\&quot;http://www.w3.org/1999/XSL/Transform\&quot; xmlns:cmswrt=\&quot;http://schemas.microsoft.com/WebPart/v3/Publishing/runtime\&quot; exclude-result-prefixes=\&quot;xsl cmswrt x\&quot; &amp;gt; &amp;lt;xsl:import href=\&quot;/Style Library/XSL Style Sheets/Header.xsl\&quot; /&amp;gt; &amp;lt;xsl:import href=\&quot;/Style Library/XSL Style Sheets/ItemStyle.xsl\&quot; /&amp;gt; &amp;lt;xsl:import href=\&quot;/Style Library/XSL Style Sheets/ContentQueryMain.xsl\&quot; /&amp;gt; &amp;lt;/xsl:stylesheet&amp;gt;&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.SampleData = &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;dsQueryResponse&amp;gt;&amp;lt;Rows&amp;gt;&amp;lt;Row Title=\&quot;Item 1\&quot; LinkUrl=\&quot;http://Item1\&quot; Group=\&quot;Group Header\&quot; __begincolumn=\&quot;True\&quot; __begingroup=\&quot;True\&quot; /&amp;gt;&amp;lt;Row Title=\&quot;Item 2\&quot; LinkUrl=\&quot;http://Item2\&quot; __begincolumn=\&quot;False\&quot; __begingroup=\&quot;False\&quot; /&amp;gt;&amp;lt;Row Title=\&quot;Item 3\&quot; LinkUrl=\&quot;http://Item3\&quot; __begincolumn=\&quot;False\&quot; __begingroup=\&quot;False\&quot; /&amp;gt;&amp;lt;/Rows&amp;gt;&amp;lt;/dsQueryResponse&amp;gt;&quot;&lt;/span&gt;;
            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ParameterBindings = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;

            &lt;span class=&quot;rem&quot;&gt;//Root Web&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (SPWeb _web = SPContext.Current.Site.RootWeb)
            {
                &lt;span class=&quot;rem&quot;&gt;//Assign the list to the CQWP&lt;/span&gt;
                SPList _listYCLToolBar = _web.GetListFromUrl(ListUrl);

                &lt;span class=&quot;rem&quot;&gt;//Data mapping&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.DataMappings = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Description:|LinkUrl:{2},TargetUrl,URL;|Title:{4},Title,Text;|NumComments:|PublishedDate:|PostCategory:|ImageUrlAltText:{0},Title,Text;|Author:|Language:{3},Language,Lookup;|ImageUrl:{1},Icon,URL;|Body:|&quot;&lt;/span&gt;
                    , _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Title&quot;&lt;/span&gt;].Id.ToString()
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Icon&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;TargetUrl&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Language&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Title&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    );

                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ListGuid = _listYCLToolBar.ID.ToString();

                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.DataMappingViewFields = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0},URL;{1},URL;{2},Text;{3},Lookup;&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;TargetUrl&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Icon&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Title&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    , &lt;span class=&quot;str&quot;&gt;&quot;{&quot;&lt;/span&gt; + _listYCLToolBar.Fields[&lt;span class=&quot;str&quot;&gt;&quot;Language&quot;&lt;/span&gt;].Id.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;}&quot;&lt;/span&gt;
                    );
                
                &lt;span class=&quot;rem&quot;&gt;//Filter One&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FilterField1 = &lt;span class=&quot;str&quot;&gt;&quot;Language&quot;&lt;/span&gt;;&lt;span class=&quot;rem&quot;&gt;//Custom Field to get the variation work.&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FilterOperator1 = FilterFieldQueryOperator.Eq;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FilterValue1 = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FilterType1 = &lt;span class=&quot;str&quot;&gt;&quot;Lookup&quot;&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Filter1ChainingOperator = FilterChainingOperator.Or;

                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.Filter2ChainingOperator = FilterChainingOperator.Or;

                &lt;span class=&quot;rem&quot;&gt;//Sorting&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.SortByFieldType = &lt;span class=&quot;str&quot;&gt;&quot;DateTime&quot;&lt;/span&gt;;
                &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.SortBy = &lt;span class=&quot;str&quot;&gt;&quot;Created&quot;&lt;/span&gt;;
            }            
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Create Child Controls&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; CreateChildControls()
        {
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.CreateChildControls();
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;i&gt;Please let me know if there is any issue with this code or you can also correct me if I am wrong.&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/7931299862652985721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/override-content-query-webpart-to-do-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/7931299862652985721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/7931299862652985721'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/override-content-query-webpart-to-do-on.html' title='Override Content Query Webpart to do on the run filteration.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5227253749820526428</id><published>2012-09-20T09:21:00.003+05:30</published><updated>2014-05-29T04:07:55.781+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Feature Event Receiver"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="ListViewWebPart"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Designer 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Error"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="WebPart"/><title type='text'>Sharepoint 2010 Error Solution : The Visible property cannot be set on Web Part &#39;g_XXX&#39;.  It can only be set on a standalone Web Part.</title><content type='html'>&lt;h3&gt;Problem&lt;/h3&gt;
There is an issue with OOTB SharePoint logic.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Scenario&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;2 types of Users
&lt;ul&gt;
&lt;li&gt;User1 is Site Administrator&lt;/li&gt;
&lt;li&gt;User2 is a simple user with Read, Limited Access.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Issue comes under blog site.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;How to reproduce? Follow the below given test case.&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Create a site collection. In my case I have created it on &quot;http://pc92&quot;.&lt;/li&gt;
&lt;li&gt;I create a blog site with name &quot;TestBlog&quot; using User1. In my case it is &quot;http://pc92/TestBlog/&quot;.&lt;/li&gt;
&lt;li&gt;Navigate to default blog created on site and add 11 comments. Right now the URL will be &quot;http://pc92/TestBlog/Lists/Posts/Post.aspx?ID=1&quot;. This will enable the paging at the comments webpart. &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggeaLy3_BPz1uSwW1497by3D8ELu-cKBsacnxJg7NXJIugFQuoTMBPtCZPiKuKcep6_LzQGTzR0PfJAawjDggMLPrd1Wah7KLOVmzw-m-LVBHDyrOhzRdY6CYQe9FL3paRlTD_Yo-m_A/s1600/02.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;295&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggeaLy3_BPz1uSwW1497by3D8ELu-cKBsacnxJg7NXJIugFQuoTMBPtCZPiKuKcep6_LzQGTzR0PfJAawjDggMLPrd1Wah7KLOVmzw-m-LVBHDyrOhzRdY6CYQe9FL3paRlTD_Yo-m_A/s320/02.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Now login with User2(Read, Limited Access User) and navigate to the URL &quot;http://pc92/TestBlog/Lists/Posts/Post.aspx?ID=1&quot;. The page will show normal. The only difference here is you won&#39;t see the &quot;Add Comment&quot; box at the bottom of the screen.&lt;/li&gt;
&lt;li&gt;Click the next button. You will see the error.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHbrPJ_TB-EXWMihDD7TcpW1i8ts0DBi4Nop22_GYxxBNSC06-YWpECj_L6bBinIJOxh1eHkxuFRG5hs0jVMuJLb1X3uCTexKCEzRoaj0RS6fvOywhmMs1O-ue2tZKM0svP-0vLLc1gA/s1600/01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;145&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHbrPJ_TB-EXWMihDD7TcpW1i8ts0DBi4Nop22_GYxxBNSC06-YWpECj_L6bBinIJOxh1eHkxuFRG5hs0jVMuJLb1X3uCTexKCEzRoaj0RS6fvOywhmMs1O-ue2tZKM0svP-0vLLc1gA/s320/01.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Cause&lt;/h3&gt;
The cause of the whole act is when you login as a User2(Read, Limited Access) the Comment Box(ListFormWebPart) is not available for this users. On page load everything is fine. But when you do a postback like paging event it bombs out. This might have got out of the site of MicroSoft Team. 
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
I created 2 features, one is a site based feature(BlogFixSite) and another one web based feature(BlogFixWeb). On the BlogFixSite activation we check all the web which doesnot have BlogFixWeb activated and the template is a Blog template. So if the feature is activated I assume that the site is already having a fix. In the BlogFixWeb I go to the &quot;Posts&quot; folder and copy &quot;Post.aspx&quot; content and create &quot;Post1.aspx&quot;. In the &quot;Post1.aspx&quot; i will remove the &quot;ListFormWebPart&quot; programatically. In &quot;Post.aspx&quot; at the bottom i will place a jquery which will check if the &quot;Add Comment&quot; box is missing than take the user to &quot;Post1.aspx&quot;. Repeat the above given test cases and you should be all good.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;BlogFixSite - C#&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.InteropServices;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Security.Permissions;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Administration;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; BlogFix.Features.BlogFixSite
{
    [Guid(&lt;span class=&quot;str&quot;&gt;&quot;63c859cc-77ff-436e-a79e-b4619a67c7c3&quot;&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; BlogFixSiteEventReceiver : SPFeatureReceiver
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Events

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Activating&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;properties&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties properties)
        {
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.FeatureActivated(properties);

            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                &lt;span class=&quot;rem&quot;&gt;//Site object&lt;/span&gt;
                SPSite _site = (SPSite)properties.Feature.Parent;

                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_site != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    &lt;span class=&quot;rem&quot;&gt;//Feature ID - BlogFixWeb&lt;/span&gt;
                    Guid _featureWeGuid = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Guid(&lt;span class=&quot;str&quot;&gt;&quot;c7178a85-ed45-4f27-bd4a-db2ec3eed95b&quot;&lt;/span&gt;);

                    &lt;span class=&quot;rem&quot;&gt;//Web List&lt;/span&gt;
                    IList&amp;lt;SPWeb&amp;gt; _webList = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _web &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _site.AllWebs.Cast&amp;lt;SPWeb&amp;gt;()
                                             where &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare(_web.WebTemplate, &lt;span class=&quot;str&quot;&gt;&quot;Blog&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;) == 0
                                                 &amp;amp;&amp;amp; _web.Features[_featureWeGuid] == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;
                                             select _web).ToList();

                    &lt;span class=&quot;rem&quot;&gt;//Change the post page&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (SPWeb _web &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _webList)
                    {
                        &lt;span class=&quot;rem&quot;&gt;//Enables the feature - BlogFixWeb&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_web.Features[_featureWeGuid] == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                        {
                            _web.Features.Add(_featureWeGuid);
                        }
                    }
                }
            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (Exception Exc)
            {
                SPDiagnosticsService.Local.WriteTrace(0, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SPDiagnosticsCategory(&lt;span class=&quot;str&quot;&gt;&quot;BlogFixSiteEventReceiver - Activated&quot;&lt;/span&gt;, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, Exc.Message, Exc.StackTrace);
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;BlogFixWeb - C#&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.InteropServices;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Security.Permissions;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Security;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Administration;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; BlogFix.Features.BlogFixWeb
{
    [Guid(&lt;span class=&quot;str&quot;&gt;&quot;564b0ad9-90a0-45fc-a672-901ec1fd111b&quot;&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; BlogFixWebEventReceiver : SPFeatureReceiver
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Events

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Activate the web based feautre&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;properties&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; FeatureActivated(SPFeatureReceiverProperties properties)
        {
            &lt;span class=&quot;kwrd&quot;&gt;base&lt;/span&gt;.FeatureActivated(properties);

            &lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
            {
                SPWeb _web = (SPWeb)properties.Feature.Parent;

                &lt;span class=&quot;rem&quot;&gt;//All the subfolders&lt;/span&gt;
                SPFolderCollection _folderCollection = _web.Folders[&lt;span class=&quot;str&quot;&gt;&quot;Lists&quot;&lt;/span&gt;].SubFolders;

                &lt;span class=&quot;rem&quot;&gt;//Finds the folder containing Post.aspx&lt;/span&gt;
                IList&amp;lt;SPFolder&amp;gt; _folderPostList = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _folderX &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderCollection.Cast&amp;lt;SPFolder&amp;gt;()
                                                   let _fName = _folderX.Name
                                                   let _fCount = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _fileX &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderX.Files.Cast&amp;lt;SPFile&amp;gt;()
                                                                  where &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare(_fileX.Name, &lt;span class=&quot;str&quot;&gt;&quot;post.aspx&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;) == 0
                                                                  select _fileX).Count()
                                                   where _fCount &amp;gt; 0
                                                   select _folderX).ToList();


                &lt;span class=&quot;rem&quot;&gt;//Loop it if there are more than one&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_folderPostList != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                {
                    &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (SPFolder _folderPost &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderPostList)
                    {
                        &lt;span class=&quot;rem&quot;&gt;//Get the Post file&lt;/span&gt;
                        SPFile _filePost = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _fileX &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _folderPost.Files.Cast&amp;lt;SPFile&amp;gt;()
                                            where &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare(_fileX.Name, &lt;span class=&quot;str&quot;&gt;&quot;post.aspx&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;) == 0
                                            select _fileX).FirstOrDefault();

                        &lt;span class=&quot;rem&quot;&gt;//The file post to be copied&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_filePost != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                        {
                            &lt;span class=&quot;rem&quot;&gt;//New Post1.aspx URL&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _newPostUrl = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}/{1}/{2}&quot;&lt;/span&gt;,
                                _web.Url,
                                _folderPost.Url,
                                &lt;span class=&quot;str&quot;&gt;&quot;Post1.aspx&quot;&lt;/span&gt;);

                            &lt;span class=&quot;rem&quot;&gt;//Copy the file&lt;/span&gt;
                            _filePost.CopyTo(_newPostUrl, &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
                            
                            &lt;span class=&quot;rem&quot;&gt;//Update the folder&lt;/span&gt;
                            _folderPost.Update();

                            &lt;span class=&quot;rem&quot;&gt;//Remove the control once the page is copied&lt;/span&gt;
                            Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager _webPartCollection = _web.GetLimitedWebPartManager(_newPostUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                            &lt;span class=&quot;rem&quot;&gt;//Retrive the webpart and remove&lt;/span&gt;
                            Microsoft.SharePoint.WebPartPages.WebPart _listFormWebPart = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _wp &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _webPartCollection.WebParts.Cast&amp;lt;Microsoft.SharePoint.WebPartPages.WebPart&amp;gt;()
                                                                                          where _wp.GetType().UnderlyingSystemType.Name == &lt;span class=&quot;str&quot;&gt;&quot;ListFormWebPart&quot;&lt;/span&gt;
                                                                                          select _wp).FirstOrDefault();


                            &lt;span class=&quot;rem&quot;&gt;//Microsoft.SharePoint.WebPartPages.ListFormWebPart _XlistFormWebPart = (Microsoft.SharePoint.WebPartPages.ListFormWebPart)_listFormWebPart;&lt;/span&gt;
                            &lt;span class=&quot;rem&quot;&gt;//string _webPartTitle = _XlistFormWebPart.Title&lt;/span&gt;
                            &lt;span class=&quot;rem&quot;&gt;//return;&lt;/span&gt;

                            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_listFormWebPart != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
                            {
                                &lt;span class=&quot;rem&quot;&gt;//Remove the webpart&lt;/span&gt;
                                _webPartCollection.DeleteWebPart(_listFormWebPart);

                                &lt;span class=&quot;rem&quot;&gt;//Update&lt;/span&gt;
                                _web.Update();
                            }

                            &lt;span class=&quot;rem&quot;&gt;//Modify Post1.aspx and add the javascript tag&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_filePost.RequiresCheckout)
                            {
                                _filePost.CheckOut();
                            }

                            &lt;span class=&quot;rem&quot;&gt;//Edit the file&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[] _htmlByte = _filePost.OpenBinary();
                            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _html = System.Text.Encoding.ASCII.GetString(_htmlByte);
                            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _topHtml = _html.Substring(0, _html.LastIndexOf(&lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;/asp:Content&amp;gt;&quot;&lt;/span&gt;));
                            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _stript = &lt;span class=&quot;str&quot;&gt;&quot;\n&amp;lt;script language=\&quot;javascript\&quot; type=\&quot;text/javascript\&quot;&amp;gt;!window.jQuery &amp;amp;&amp;amp; document.write(&#39;&amp;lt;script src=\&quot;http://code.jquery.com/jquery-1.4.2.min.js\&quot;&amp;gt;&amp;lt;\\/script&amp;gt;&#39;);&amp;lt;/script&amp;gt;\n&amp;lt;script language=&#39;javascript&#39;&amp;gt;\n\r$(document).ready(function(){\n\r\rif($(\&quot;h3[class=&#39;ms-CommentHeader&#39;]\&quot;).length == 1){\n\r\r\r\rwindow.location.href =     window.location.href.replace(\&quot;.aspx?\&quot; , \&quot;1.aspx?\&quot;);\n\r\r}\n\r});&amp;lt;/script&amp;gt;&quot;&lt;/span&gt;;
                                

                            _html = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;{0}{1}&amp;lt;/asp:Content&amp;gt;&quot;&lt;/span&gt;, _topHtml, _stript);
                            _filePost.SaveBinary(System.Text.Encoding.ASCII.GetBytes(_html));

                            &lt;span class=&quot;rem&quot;&gt;//Check In&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_filePost.RequiresCheckout)
                            {
                                _filePost.CheckIn(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty);
                            }
                        }
                    }
                }

            }
            &lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (Exception Exc)
            {
                SPDiagnosticsService.Local.WriteTrace(0, &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SPDiagnosticsCategory(&lt;span class=&quot;str&quot;&gt;&quot;BlogFixWebEventReceiver - Activated&quot;&lt;/span&gt;, TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, Exc.Message, Exc.StackTrace);
            }
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;JavaScript added on Post.aspx&lt;/h3&gt;
There are 2 &quot;&amp;lt;h3&amp;gt;&amp;lt;/h3&amp;gt;&quot; tags on the post.aspx page. (1) is &quot;Comments&quot; and (2) is &quot;Add Comments&quot;. So if a user dont have access he/she wont see &quot;Add Comment&quot; box. If that box doesnot exists on the page I simply send the user to Post1.aspx.
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;    !window.jQuery &amp;amp;&amp;amp; document.write(&lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;script src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&#39;&lt;/span&gt;);&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;script language=&lt;span class=&quot;str&quot;&gt;&#39;javascript&#39;&lt;/span&gt;&amp;gt;
    $(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; () {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; ($(&lt;span class=&quot;str&quot;&gt;&quot;h3[class=&#39;ms-CommentHeader&#39;]&quot;&lt;/span&gt;).length == 1) {
            window.location.href = window.location.href.replace(&lt;span class=&quot;str&quot;&gt;&quot;.aspx?&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;1.aspx?&quot;&lt;/span&gt;);
        }
    });&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Final Comments&lt;/h3&gt;
To make this feature available for all the webs just create a feature stapler which activates the web based feature just like its done in &quot;BlogFixSite&quot;.&lt;br /&gt;
I know many people wont agree with my solution but right now it is what it is. Happy Coding. Do let me know if this helped you.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5227253749820526428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-error-solution-visible.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5227253749820526428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5227253749820526428'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/sharepoint-2010-error-solution-visible.html' title='Sharepoint 2010 Error Solution : The Visible property cannot be set on Web Part &#39;g_XXX&#39;.  It can only be set on a standalone Web Part.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggeaLy3_BPz1uSwW1497by3D8ELu-cKBsacnxJg7NXJIugFQuoTMBPtCZPiKuKcep6_LzQGTzR0PfJAawjDggMLPrd1Wah7KLOVmzw-m-LVBHDyrOhzRdY6CYQe9FL3paRlTD_Yo-m_A/s72-c/02.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5355237866440554752</id><published>2012-09-04T19:08:00.000+05:30</published><updated>2012-09-04T19:08:01.749+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="CSS"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><title type='text'>JQuery : Quick paging solution with JQuery</title><content type='html'>&lt;h1&gt;Goal&lt;/h1&gt;
Many of the times we have to give the paging solutions with JQuery. I have created a small generic script that will allow you to apply paging on html table very quickly. Just a few settings and script will manage the paging(Note:- Right now the script will apply one one table on a page).
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;Settings&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Table ID :&lt;/b&gt; Apply an ID to the table with prefix &quot;rpt&quot;. In our case we have used &quot;rptPagingTable&quot;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Paging Items :&lt;/b&gt; All the rows which are going to be shown on the basis of page. Apply a custom tag to the row(tag=&quot;item&quot;).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Next/Previous :&lt;/b&gt; The paging box will have a tag(tag=&quot;paging&quot;). There are seperate tags assigned to the button Next and Previous. For Previous it is (tag=&quot;pre&quot;) and for Next it is (tag=&quot;next&quot;).&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;Solution&lt;/h1&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;style&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        body{font-family:Calibri,Verdana,Arial,Times New Roman;}
        .datagrid{border: 1px solid #808080;}
        .datagrid td{border: 1px solid #efefef;border-collapse: none;padding: 5px;}
        .header{background-color: #808080;color: #fff;text-align: center;font-size: 20px;}
        .itemtemplate{background-color: #fff;}
        .alternatingitemtemplate{background-color: #efefdf;}
        .footer{background-color: #808080;color: #fff;font-size: 15px;}
        .pager{background-color: #CED3D6;color: #000;font-size: 15px;text-align: center;}
        .pager a{color: #0877BD;}
        .pre{float: left;}
        .next{float: right;}
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;!window.jQuery &amp;amp;&amp;amp; document.write(&lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;script src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&#39;&lt;/span&gt;);&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &amp;lt;script language=&lt;span class=&quot;str&quot;&gt;&quot;javascript&quot;&lt;/span&gt; type=&lt;span class=&quot;str&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&amp;gt;
        &lt;span class=&quot;rem&quot;&gt;//CODE WHICH WILL HELP IN PAGING&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;//Variable for paging&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _currentPage = 1;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _pageSize = 0;
        &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _totalPages = 1;

        $(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; () {

            &lt;span class=&quot;rem&quot;&gt;//Setting the page size&lt;/span&gt;
            _pageSize = $(&lt;span class=&quot;str&quot;&gt;&quot;table[id*=&#39;rpt&#39;]&quot;&lt;/span&gt;).attr(&lt;span class=&quot;str&quot;&gt;&quot;pagesize&quot;&lt;/span&gt;);

            &lt;span class=&quot;rem&quot;&gt;//Total Item&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _trItem = $(&lt;span class=&quot;str&quot;&gt;&quot;tr[tag=&#39;item&#39;]&quot;&lt;/span&gt;);
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _pager = $(&lt;span class=&quot;str&quot;&gt;&quot;tr[tag=&#39;paging&#39;]&quot;&lt;/span&gt;);

            &lt;span class=&quot;rem&quot;&gt;//Calculate the page size&lt;/span&gt;
            _totalPages = parseInt($(_trItem).length / _pageSize) + ($(_trItem).length % _pageSize &amp;gt; 0 ? 1 : 0);

            &lt;span class=&quot;rem&quot;&gt;//Hide the pager if the items are less than 13&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; ($(_trItem).length &amp;gt; _pageSize) {
                $(_pager).show();
            }
            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; {
                $(_pager).hide();
            }

            &lt;span class=&quot;rem&quot;&gt;//Page One Settings&lt;/span&gt;
            Paging();

            &lt;span class=&quot;rem&quot;&gt;//Previous&lt;/span&gt;
            $(&lt;span class=&quot;str&quot;&gt;&quot;a[tag=&#39;pre&#39;]&quot;&lt;/span&gt;).click(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; () {

                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_currentPage == 1) {
                    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;
                }

                &lt;span class=&quot;rem&quot;&gt;//Reduce the page index&lt;/span&gt;
                _currentPage = _currentPage - 1;

                &lt;span class=&quot;rem&quot;&gt;//Paging&lt;/span&gt;
                Paging();
            });

            &lt;span class=&quot;rem&quot;&gt;//Next&lt;/span&gt;
            $(&lt;span class=&quot;str&quot;&gt;&quot;a[tag=&#39;next&#39;]&quot;&lt;/span&gt;).click(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; () {

                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_currentPage == _totalPages) {
                    &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt;;
                }

                &lt;span class=&quot;rem&quot;&gt;//Increase the page index&lt;/span&gt;
                _currentPage = _currentPage + 1;

                &lt;span class=&quot;rem&quot;&gt;//Paging&lt;/span&gt;
                Paging();
            });

        });

        &lt;span class=&quot;rem&quot;&gt;//Shows/Hides the tr&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; Paging() {

            &lt;span class=&quot;rem&quot;&gt;//Get the correct start index and end index&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _endIndex = (_currentPage * _pageSize);
            &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _startIndex = (_endIndex - _pageSize) + 1;

            &lt;span class=&quot;rem&quot;&gt;//Hide all first&lt;/span&gt;
            $(&lt;span class=&quot;str&quot;&gt;&quot;tr[tag=&#39;item&#39;]&quot;&lt;/span&gt;).hide();

            &lt;span class=&quot;rem&quot;&gt;//Show correct items&lt;/span&gt;
            $(&lt;span class=&quot;str&quot;&gt;&quot;tr[tag=&#39;item&#39;]&quot;&lt;/span&gt;).each(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; (i) {
                &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; x = i + 1;
                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (x &amp;gt;= _startIndex &amp;amp;&amp;amp; x &amp;lt;= _endIndex) {
                    $(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;).show();
                }
            });
        }

    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;rptPagingTable&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;cellpadding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;cellspacing&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;datagrid&quot;&lt;/span&gt;
        &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;width: 700px&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;align&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;calculativegrid&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;PM&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;pagesize&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;5&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;header&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;No.&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;width: 100%;&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Instant Paging&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;1&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Ahmedabad&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;2&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Mumbai&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;3&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Delhi&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;4&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Calcutta&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;5&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Chicago&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;6&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;New York&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;7&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;New Jersy&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;8&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Bangalore&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;9&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Hyderabad&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;10&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Noida&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;itemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;11&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Mangalore&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;item&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&#39;alternatingitemtemplate&#39;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;12&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Pune&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;paging&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;pager&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;colspan&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;6&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;pre&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;pre&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:void(0);&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&amp;lt;&lt;/span&gt; Prev&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;tag&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;next&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;next&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:void(0);&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;Next &lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;   
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;Display&lt;/h1&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1rhQi2hYWFVXctwWCsBudO22tBlmAZ0vrZZzbd9d18JhUmvE0biX7BKyoHBma9b_HgpWlA_i7GJX31N9FQS0y2FMq6FKBCMu6_WVElsNOhMSUlZSoKEJ-yei4AuUO7FvUtJzlaDRVQ/s1600/Image1.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;304&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1rhQi2hYWFVXctwWCsBudO22tBlmAZ0vrZZzbd9d18JhUmvE0biX7BKyoHBma9b_HgpWlA_i7GJX31N9FQS0y2FMq6FKBCMu6_WVElsNOhMSUlZSoKEJ-yei4AuUO7FvUtJzlaDRVQ/s320/Image1.png&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
Please let me know if this was helpful.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5355237866440554752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/jquery-quick-paging-solution-with-jquery.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5355237866440554752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5355237866440554752'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/09/jquery-quick-paging-solution-with-jquery.html' title='JQuery : Quick paging solution with JQuery'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1rhQi2hYWFVXctwWCsBudO22tBlmAZ0vrZZzbd9d18JhUmvE0biX7BKyoHBma9b_HgpWlA_i7GJX31N9FQS0y2FMq6FKBCMu6_WVElsNOhMSUlZSoKEJ-yei4AuUO7FvUtJzlaDRVQ/s72-c/Image1.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-6206071688012335764</id><published>2012-06-19T11:01:00.001+05:30</published><updated>2012-07-06T09:54:53.876+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="REST"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Service"/><title type='text'>WCF Services : Simplest way to create a WCF REST(Representational State Transfer) service.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
To create a WCF REST(Representational State Transfer) service. The main goal is to show it in the most simplest way.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Follow the below given steps&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open Visual Studio 2010.&lt;/li&gt;
&lt;li&gt;File &gt;&gt; New Project &gt;&gt; WCF &gt;&gt; WCF Service Application. I named it SimpleWCFService.&lt;/li&gt;
&lt;li&gt;I removed the default &quot;IService1.cs&quot; and &quot;Service1.svc&quot;. Added a new &quot;Sample.svc&quot;. This will automatically create an interface in file &quot;ISample.cs&quot;. The structure will look like the image given below.&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCbd5POxms80I9iPCZ5rAi9mxd6n2u2LPjCEIGy0cBgS8NUOg7LZBkjijq7RFpG8Xke5UYqvkiK6ZirmoI15SECgYY7LB_R5Algi-NWCb14NswW8at14G9KiNREy6fHp8hU-m80dAfdw/s1600/01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; width=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCbd5POxms80I9iPCZ5rAi9mxd6n2u2LPjCEIGy0cBgS8NUOg7LZBkjijq7RFpG8Xke5UYqvkiK6ZirmoI15SECgYY7LB_R5Algi-NWCb14NswW8at14G9KiNREy6fHp8hU-m80dAfdw/s320/01.png&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;ISample.cs&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ServiceModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ServiceModel.Web;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; SimpleWCFService
{
    [ServiceContract]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;interface&lt;/span&gt; ISample
    {
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The parameters are passed in URL expression.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param1&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param2&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        [OperationContract]
        [WebGet(UriTemplate = &lt;span class=&quot;str&quot;&gt;&quot;SampleCheck/{Param1}/{Param2}&quot;&lt;/span&gt;)]
        &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; SampleCheckUrl(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param1, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param2);

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The parameters are passed as QueryString.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param1&quot;&amp;gt;{Param1}&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param2&quot;&amp;gt;{Param2}&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        [OperationContract]
        [WebGet(UriTemplate = &lt;span class=&quot;str&quot;&gt;&quot;SampleCheck?Param1={Param1}&amp;amp;Param2={Param2}&quot;&lt;/span&gt;)]
        &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; SampleCheckQueryString(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param1, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param2);
    }
}
&lt;/pre&gt;

&lt;h3&gt;Sample.svc.cs&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Runtime.Serialization;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ServiceModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.Script.Serialization;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; SimpleWCFService
{

    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Simple Class&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [DataContract]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SimpleClass
    {
        [DataMember]
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; CParam1 { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        [DataMember]
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; CParam2 { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        [DataMember]
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; CMessage { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    }


    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// The simplest way to use a WCF REST(Representational State Transfer) service&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Sample : ISample
    {

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The parameters are passed in URL expression.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param1&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param2&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; SampleCheckUrl(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param1, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param2)
        {
            JavaScriptSerializer _jScript = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer();
            SimpleClass _simple = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SimpleClass()
            {
                CParam1 = Param1,
                CParam2 = Param2,
                CMessage = &lt;span class=&quot;str&quot;&gt;&quot;Success with SampleCheckUrl(int Param1, string Param2)!&quot;&lt;/span&gt;
            };
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _jScript.Serialize(_simple);            
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The parameters are passed as QueryString.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param1&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;Param2&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; SampleCheckQueryString(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param1, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Param2)
        {
            JavaScriptSerializer _jScript = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; JavaScriptSerializer();
            SimpleClass _simple = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SimpleClass()
            {
                CParam1 = Param1,
                CParam2 = Param2,
                CMessage = &lt;span class=&quot;str&quot;&gt;&quot;Success with SampleCheckQueryString(int Param1, string Param2)!&quot;&lt;/span&gt;
            };
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _jScript.Serialize(_simple);
        }
    }
}
&lt;/pre&gt;

&lt;h3&gt;Web.config - MOST IMPORTANT&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xml&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1.0&quot;&lt;/span&gt;?&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.web&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;compilation&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;targetFramework&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;4.0&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.web&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleWCFServiceBC&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceMetadata&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;httpGetEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceDebug&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;serviceBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpointBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;restBehaviour&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;webHttp&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;automaticFormatSelectionEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;helpEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behavior&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpointBehaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;behaviors&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;bindings&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;webHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;binding&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RestBinding&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;webHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;basicHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;basicHttpBinding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;bindings&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleWCFService.Sample&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleWCFServiceBC&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;basicHttpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;contract&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleWCFService.ISample&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;rest&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;webHttpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;behaviorConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;restBehaviour&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;bindingConfiguration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;RestBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;contract&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleWCFService.ISample&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;endpoint&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;contract&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;IMetadataExchange&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;binding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;mexHttpBinding&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;mex&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.serviceModel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.webServer&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;modules&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runAllManagedModulesForAllRequests&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;system.webServer&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;configuration&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;h3&gt;Checking REST Service - URL FORMAT&lt;/h3&gt;
Navigate to the below given url(&lt;i&gt;Note:Replace the port number.&lt;/i&gt;).
&lt;br /&gt;&quot;http://{LOCALHOST:PORTNUMBER}/Sample.svc/rest/SampleCheck/Args1/Args2&quot;.&lt;br /&gt;This should give the result in below given format.&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;{&quot;CParam1&quot;:&quot;Args1&quot;,&quot;CParam2&quot;:&quot;Args2&quot;,&quot;CMessage&quot;:&quot;Success with SampleCheckUrl(int Param1, string Param2)!&quot;}&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;

&lt;h3&gt;Checking REST Service - QueryString&lt;/h3&gt;
Navigate to the below given url(&lt;i&gt;Note:Replace the port number.&lt;/i&gt;).
&lt;br /&gt;&quot;http://{LOCALHOST:PORTNUMBER/Sample.svc/rest/SampleCheck?Param1=Args1&amp;Param2=Args2&quot;.&lt;br /&gt;This should give the result in below given format.
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/2003/10/Serialization/&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;{&quot;CParam1&quot;:&quot;Args1&quot;,&quot;CParam2&quot;:&quot;Args2&quot;,&quot;CMessage&quot;:&quot;Success with SampleCheckQueryString(int Param1, string Param2)!&quot;}&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;br/&gt;&lt;br/&gt;

I spent a lot of time trying to figure this out so writing this up for the ones who just want solutions. Let me know if this helped.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/6206071688012335764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/06/wcf-services-simplest-way-to-create-wcf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6206071688012335764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6206071688012335764'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/06/wcf-services-simplest-way-to-create-wcf.html' title='WCF Services : Simplest way to create a WCF REST(Representational State Transfer) service.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCbd5POxms80I9iPCZ5rAi9mxd6n2u2LPjCEIGy0cBgS8NUOg7LZBkjijq7RFpG8Xke5UYqvkiK6ZirmoI15SECgYY7LB_R5Algi-NWCb14NswW8at14G9KiNREy6fHp8hU-m80dAfdw/s72-c/01.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-6255787843146848932</id><published>2012-06-08T20:14:00.001+05:30</published><updated>2014-09-05T20:15:33.091+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Common Table Expression"/><category scheme="http://www.blogger.com/atom/ns#" term="CTE"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><title type='text'>SQL Server : Using CTE(Common Table Expression) fetch a Tree View</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
Using CTE show a complete tree view.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Challenge&lt;/h3&gt;
When a developer tries to search CTE in internet, there are millions of articles which already exists which says to get a tree view using CTE. But there is a problem with most of them. They dont give correct output. For making the data show in correct way users should enter data in an order, else it wont come. So first I will explain how the examples on internet mislead.
&lt;br /&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;h3 style=&quot;color:green&quot;&gt;SQL - Create temp table&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;-- DECLARE&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;DECLARE&lt;/span&gt; @Company &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;TABLE&lt;/span&gt;(EmpID &lt;span class=&quot;kwrd&quot;&gt;INT&lt;/span&gt;, ParentID &lt;span class=&quot;kwrd&quot;&gt;INT&lt;/span&gt;, PersonName &lt;span class=&quot;kwrd&quot;&gt;VARCHAR&lt;/span&gt;(100));

&lt;span class=&quot;rem&quot;&gt;-- Insert Temp Records&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;INSERT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;INTO&lt;/span&gt; @Company(EmpID, ParentID, PersonName) 
&lt;span class=&quot;kwrd&quot;&gt;VALUES&lt;/span&gt;(1 , &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt; , &lt;span class=&quot;str&quot;&gt;&#39;Maulik Dhorajia&#39;&lt;/span&gt;)
    , (2 , &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt; , &lt;span class=&quot;str&quot;&gt;&#39;Bhavesh Gohel&#39;&lt;/span&gt;)
    , (3 , &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt; , &lt;span class=&quot;str&quot;&gt;&#39;Dinesh Padhiyar&#39;&lt;/span&gt;)
    , (4 , 2 , &lt;span class=&quot;str&quot;&gt;&#39;Vijay Kumar&#39;&lt;/span&gt;)
    , (5 , 1 , &lt;span class=&quot;str&quot;&gt;&#39;Jitendra Makwana&#39;&lt;/span&gt;)
    , (6 , 4 , &lt;span class=&quot;str&quot;&gt;&#39;Jayesh Dhobi&#39;&lt;/span&gt;)
    , (7 , 1 , &lt;span class=&quot;str&quot;&gt;&#39;Shivpalsinh Jhala&#39;&lt;/span&gt;)
    , (8 , 5 , &lt;span class=&quot;str&quot;&gt;&#39;Amit Patel&#39;&lt;/span&gt;)
    , (9 , 3 , &lt;span class=&quot;str&quot;&gt;&#39;Abidali Suthar&#39;&lt;/span&gt;)

&lt;span class=&quot;rem&quot;&gt;-- Default data&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @Company;&lt;/pre&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-s-5gwoF6mCnyugySBrPpcm5NSiUMdJh49RVhcD2YpxbEJTv4ucwghofmTcVgPhn4EZZpJEGc1NIb2I8DoxShnF6qUxdnCdCh-3bM_L5NnFs-Mf7D3cBUnvaIx5zGxSHnctOOtGenbg/s1600/01.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; width=&quot;246&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-s-5gwoF6mCnyugySBrPpcm5NSiUMdJh49RVhcD2YpxbEJTv4ucwghofmTcVgPhn4EZZpJEGc1NIb2I8DoxShnF6qUxdnCdCh-3bM_L5NnFs-Mf7D3cBUnvaIx5zGxSHnctOOtGenbg/s320/01.png&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;h3 style=&quot;color:red&quot;&gt;SQL - Which usually misleads to get correct tree view&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;-- Incorrect result which we usually find on Internet&lt;/span&gt;
;&lt;span class=&quot;kwrd&quot;&gt;WITH&lt;/span&gt; CTECompany
&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;
(
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; EmpID, ParentID, PersonName , 0 &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; HLevel 
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @Company
    &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; ParentID &lt;span class=&quot;kwrd&quot;&gt;IS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;
    
    &lt;span class=&quot;kwrd&quot;&gt;UNION&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;ALL&lt;/span&gt;
    
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; C.EmpID, C.ParentID, C.PersonName , (CTE.HLevel + 1) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; HLevel 
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @Company C
    &lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; CTECompany CTE &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; CTE.EmpID = C.ParentID
    &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; C.ParentID &lt;span class=&quot;kwrd&quot;&gt;IS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;
)

&lt;span class=&quot;rem&quot;&gt;-- Misleading SQL&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt;
(
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; 
        EmpID
        , ParentID
        , HLevel
        , (REPLICATE( &lt;span class=&quot;str&quot;&gt;&#39;----&#39;&lt;/span&gt; , HLevel ) + PersonName) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; Person
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; CTECompany
) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; P
&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; HLevel;&lt;/pre&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaJGJ60OesoImCsj2C6LLFlX3rn3LJ_3gXCibjJBa-hvX7Wa9rZ1jWcbVCiZ4YkliVu1VZRryYKIjrhrKm7YoHsXUiDt7zZPKtL4K4d6BXyLUwt8x04t-ZVLQzCN8OKAXyviLRqHbRdw/s1600/02.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; width=&quot;304&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaJGJ60OesoImCsj2C6LLFlX3rn3LJ_3gXCibjJBa-hvX7Wa9rZ1jWcbVCiZ4YkliVu1VZRryYKIjrhrKm7YoHsXUiDt7zZPKtL4K4d6BXyLUwt8x04t-ZVLQzCN8OKAXyviLRqHbRdw/s320/02.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;hr /&gt;
&lt;h3 style=&quot;color:green&quot;&gt;SQL - Correct CTE with Tree View&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;-- Working Example&lt;/span&gt;
;&lt;span class=&quot;kwrd&quot;&gt;WITH&lt;/span&gt; CTECompany
&lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt;
(
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; 
        EmpID, 
        ParentID, 
        PersonName , 
        0 &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; HLevel,
        &lt;span class=&quot;kwrd&quot;&gt;CAST&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;RIGHT&lt;/span&gt;(REPLICATE(&lt;span class=&quot;str&quot;&gt;&#39;_&#39;&lt;/span&gt;,5) +  &lt;span class=&quot;kwrd&quot;&gt;CONVERT&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;VARCHAR&lt;/span&gt;(20),EmpID),20) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;MAX&lt;/span&gt;)) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; OrderByField
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @Company
    &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; ParentID &lt;span class=&quot;kwrd&quot;&gt;IS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;
    
    &lt;span class=&quot;kwrd&quot;&gt;UNION&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;ALL&lt;/span&gt;
    
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; 
        C.EmpID, 
        C.ParentID, 
        C.PersonName , 
        (CTE.HLevel + 1) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; HLevel,
        CTE.OrderByField + &lt;span class=&quot;kwrd&quot;&gt;CAST&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;RIGHT&lt;/span&gt;(REPLICATE(&lt;span class=&quot;str&quot;&gt;&#39;_&#39;&lt;/span&gt;,5) +  &lt;span class=&quot;kwrd&quot;&gt;CONVERT&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;VARCHAR&lt;/span&gt;(20),C.EmpID),20) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;VARCHAR&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;MAX&lt;/span&gt;)) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; OrderByField
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @Company C
    &lt;span class=&quot;kwrd&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;JOIN&lt;/span&gt; CTECompany CTE &lt;span class=&quot;kwrd&quot;&gt;ON&lt;/span&gt; CTE.EmpID = C.ParentID
    &lt;span class=&quot;kwrd&quot;&gt;WHERE&lt;/span&gt; C.ParentID &lt;span class=&quot;kwrd&quot;&gt;IS&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;NULL&lt;/span&gt;
)

&lt;span class=&quot;rem&quot;&gt;-- Working Example&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; 
    EmpID
    , ParentID
    , HLevel
    , PersonName
    , (REPLICATE( &lt;span class=&quot;str&quot;&gt;&#39;----&#39;&lt;/span&gt; , HLevel ) + PersonName) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; Person
&lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; CTECompany
&lt;span class=&quot;kwrd&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;BY&lt;/span&gt; OrderByField,PersonName;&lt;/pre&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3fwEMrl_3C0sMCYSE-I34G6onJzo0CniKzWlDAYgdg3r_4MhyphenhyphenCuXIp_YEOCQGseCO5IUvZrCwMUgaEu5EFCHQB01E4W2ai-9S7Nf5clc3lJ52hIpwvorqI9xIFHeLpHY4g8lWEfaHyg/s1600/03.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; width=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3fwEMrl_3C0sMCYSE-I34G6onJzo0CniKzWlDAYgdg3r_4MhyphenhyphenCuXIp_YEOCQGseCO5IUvZrCwMUgaEu5EFCHQB01E4W2ai-9S7Nf5clc3lJ52hIpwvorqI9xIFHeLpHY4g8lWEfaHyg/s320/03.png&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
Hope this helped and saved a lot of your time!
&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;color:green&quot;&gt;
Reply for the comment &quot;Nice try. still relies on order of data entry. add (44 , 1 , &#39;XXitendra Makwana&#39;)&quot;. I tried to see what was wrong but I can see the correct tree with the same query. Not sure what is wrong. Can anyone else see the issue and post a comment? Thanks in advance.
&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpy3nOlxeWsNl7TravaLAkZsLm0xbB-CBsoZago8CM3ozHbqCL1ROOllNafvZtOHHVaSRXrZcCnJ-EsPTiomcMJMRqxynPSl94rR_R3FICamHPeWpa8wl3hT683Xfn5h5SkvDqVP7UpA/s1600/Result+for+reply.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpy3nOlxeWsNl7TravaLAkZsLm0xbB-CBsoZago8CM3ozHbqCL1ROOllNafvZtOHHVaSRXrZcCnJ-EsPTiomcMJMRqxynPSl94rR_R3FICamHPeWpa8wl3hT683Xfn5h5SkvDqVP7UpA/s320/Result+for+reply.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/6255787843146848932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/06/sql-server-using-ctecommon-table.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6255787843146848932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6255787843146848932'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/06/sql-server-using-ctecommon-table.html' title='SQL Server : Using CTE(Common Table Expression) fetch a Tree View'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-s-5gwoF6mCnyugySBrPpcm5NSiUMdJh49RVhcD2YpxbEJTv4ucwghofmTcVgPhn4EZZpJEGc1NIb2I8DoxShnF6qUxdnCdCh-3bM_L5NnFs-Mf7D3cBUnvaIx5zGxSHnctOOtGenbg/s72-c/01.png" height="72" width="72"/><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5633033338658024269</id><published>2012-05-19T15:26:00.002+05:30</published><updated>2012-05-19T15:26:48.156+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dismount-SPContentDatabase"/><category scheme="http://www.blogger.com/atom/ns#" term="Mount-SPContentDatabase"/><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><title type='text'>PowerShell : Mount-SPContentDatabase / Dismount-SPContentDatabase database</title><content type='html'>&lt;h3&gt;Situation&lt;/h3&gt;
If a client provides a database backup of the SharePoint site running on their server and we want to use that database in our environment. Using powershell we have to change the mounting of database and use the database what client sent.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Prerequesites&lt;/h3&gt;
Restore the database given by client in your Sharepoint database instance. Once that is done run the below given powershell in &quot;SharePoint 2010 Management Shell&quot;.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Powershell&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;# Url of the site collection which the database is going to point&lt;/span&gt;
$SiteUrl = &lt;span class=&quot;str&quot;&gt;&quot;http://MyMachine&quot;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;# The current database site is using.&lt;/span&gt;
$CurrentContentDatabase = &lt;span class=&quot;str&quot;&gt;&quot;WSS_Content&quot;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;# New database which the site will point&lt;/span&gt;
$NewContentDatabase = &lt;span class=&quot;str&quot;&gt;&quot;WSS_Content_NewDB&quot;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;# SQL SERVER Instanne&lt;/span&gt;
$DatabaseServer = &lt;span class=&quot;str&quot;&gt;&quot;MYMachine\SHAREPOINT&quot;&lt;/span&gt;

&lt;span class=&quot;rem&quot;&gt;# The command will dismount the current databae&lt;/span&gt;
Dismount-SPContentDatabase -Identity $CurrentContentDatabase -confirm:$false

&lt;span class=&quot;rem&quot;&gt;# Mounts the new database&lt;/span&gt;
Mount-SPContentDatabase -name $NewContentDatabase -DatabaseServer $DatabaseServer -WebApplication $SiteUrl -confirm:$false&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5633033338658024269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/powershell-mount-spcontentdatabase.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5633033338658024269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5633033338658024269'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/powershell-mount-spcontentdatabase.html' title='PowerShell : Mount-SPContentDatabase / Dismount-SPContentDatabase database'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-4165017982029799805</id><published>2012-05-18T16:41:00.000+05:30</published><updated>2012-05-18T16:41:02.350+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ADO.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="DataTable"/><category scheme="http://www.blogger.com/atom/ns#" term="Group By Clause"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><title type='text'>Apply &quot;Multiple&quot; column Group By on DataTable in C#</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
A few days ago a reader asked for Multiple column group by on DataTable. This blos is in reply of that question. This was my old blog &lt;a href=&quot;http://maulikdhorajia.blogspot.in/2010/08/apply-group-by-clause-on-datatable-in-c.html&quot;&gt;Apply group by clause on Datatable in C#&lt;/a&gt;.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Data;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; SampleApplication
{
    &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Enums

    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// The functions which can be used for aggreation&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; AggregateFunction
    {
        Sum,
        Avg,
        Count,
        Max,
        Min
    }

    &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

    &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Entity

    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// The class which will have properties of function to be performed and on which field&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; DataTableAggregateFunction
    {
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The function to be performed&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; AggregateFunction enmFunction { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Performed for which column&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; ColumnName { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// What should be the name after output&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; OutPutColumnName { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }
    }

    &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Helper
    {
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Demo for Group By&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; DemoGroupBy()
        { 
            &lt;span class=&quot;rem&quot;&gt;//Gets the mock data table&lt;/span&gt;
            DataTable _dt = GetDataTable();

            &lt;span class=&quot;rem&quot;&gt;//Add columns which you want to group by&lt;/span&gt;
            IList&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt; _groupByColumnNames = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;();
            _groupByColumnNames.Add(&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;);
            _groupByColumnNames.Add(&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;);

            &lt;span class=&quot;rem&quot;&gt;//Functions you want to perform on which fields&lt;/span&gt;
            IList&amp;lt;DataTableAggregateFunction&amp;gt; _fieldsForCalculation = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; List&amp;lt;DataTableAggregateFunction&amp;gt;();
            _fieldsForCalculation.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTableAggregateFunction() { enmFunction = AggregateFunction.Avg, ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;, OutPutColumnName = &lt;span class=&quot;str&quot;&gt;&quot;PopulationAvg&quot;&lt;/span&gt; });
            _fieldsForCalculation.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTableAggregateFunction() { enmFunction = AggregateFunction.Sum, ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;, OutPutColumnName = &lt;span class=&quot;str&quot;&gt;&quot;PopulationSum&quot;&lt;/span&gt; });
            _fieldsForCalculation.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTableAggregateFunction() { enmFunction = AggregateFunction.Count, ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;, OutPutColumnName = &lt;span class=&quot;str&quot;&gt;&quot;PopulationCount&quot;&lt;/span&gt; });
            _fieldsForCalculation.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTableAggregateFunction() { enmFunction = AggregateFunction.Max, ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;, OutPutColumnName = &lt;span class=&quot;str&quot;&gt;&quot;YearMax&quot;&lt;/span&gt; });
            _fieldsForCalculation.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTableAggregateFunction() { enmFunction = AggregateFunction.Min, ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;, OutPutColumnName = &lt;span class=&quot;str&quot;&gt;&quot;YearMin&quot;&lt;/span&gt; });

            &lt;span class=&quot;rem&quot;&gt;//Gets the result after grouping by&lt;/span&gt;
            DataTable dtGroupedBy = GetGroupedBy(_dt, _groupByColumnNames, _fieldsForCalculation);
        }


        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Returns a mock data table&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; DataTable GetDataTable()
        {
            &lt;span class=&quot;rem&quot;&gt;//Declarations&lt;/span&gt;
            DataTable _dt = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTable();
            DataRow _dr;
            
            &lt;span class=&quot;rem&quot;&gt;//Create columns&lt;/span&gt;
            _dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataColumn() { ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt; });
            _dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataColumn() { ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt; });
            _dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataColumn() { ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;, DataType = &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(System.Int32) });
            _dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataColumn() { ColumnName = &lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;, DataType = &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(System.Int32) });

            &lt;span class=&quot;rem&quot;&gt;//Add mock data&lt;/span&gt;
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Ahmedabad&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2009; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 6000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Surat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2009; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 2000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Rajkot&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2009; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 1000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Maharastra&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Mumbai&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2009; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 3000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Maharastra&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Pune&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2009; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 3000000; _dt.Rows.Add(_dr);

            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Ahmedabad&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2010; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 8000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Maharastra&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Mumbai&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2010; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 8000000; _dt.Rows.Add(_dr);

            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Ahmedabad&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2011; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 6000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Surat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2011; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 2000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Gujarat&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Rajkot&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2011; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 1000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Maharastra&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Mumbai&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2011; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 3000000; _dt.Rows.Add(_dr);
            _dr = _dt.NewRow(); _dr[&lt;span class=&quot;str&quot;&gt;&quot;State&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Maharastra&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;City&quot;&lt;/span&gt;] = &lt;span class=&quot;str&quot;&gt;&quot;Pune&quot;&lt;/span&gt;; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Year&quot;&lt;/span&gt;] = 2011; _dr[&lt;span class=&quot;str&quot;&gt;&quot;Population&quot;&lt;/span&gt;] = 3000000; _dt.Rows.Add(_dr);

            &lt;span class=&quot;rem&quot;&gt;//Return table&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _dt;
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Group by DataTable&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_dtSource&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_groupByColumnNames&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_fieldsForCalculation&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; DataTable GetGroupedBy(DataTable _dtSource, IList&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt; _groupByColumnNames, IList&amp;lt;DataTableAggregateFunction&amp;gt; _fieldsForCalculation)
        {
            
            &lt;span class=&quot;rem&quot;&gt;//Once the columns are added find the distinct rows and group it bu the numbet&lt;/span&gt;
            DataTable _dtReturn = _dtSource.DefaultView.ToTable(&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;, _groupByColumnNames.ToArray());

            &lt;span class=&quot;rem&quot;&gt;//The column names in data table&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (DataTableAggregateFunction _calculatedField &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _fieldsForCalculation)
            {
                _dtReturn.Columns.Add(_calculatedField.OutPutColumnName);
            }

            &lt;span class=&quot;rem&quot;&gt;//Gets the collection and send it back&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; _dtReturn.Rows.Count; i = i + 1)
            {
                &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Gets the filter &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _filterString = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;
                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; j = 0; j &amp;lt; _groupByColumnNames.Count; j = j + 1)
                {
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (j &amp;gt; 0)
                    {
                        _filterString += &lt;span class=&quot;str&quot;&gt;&quot; AND &quot;&lt;/span&gt;;
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_dtReturn.Columns[_groupByColumnNames[j]].DataType == &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(System.Int32))
                    {
                        _filterString += _groupByColumnNames[j] + &lt;span class=&quot;str&quot;&gt;&quot; = &quot;&lt;/span&gt; + _dtReturn.Rows[i][_groupByColumnNames[j]].ToString() + &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
                    }
                    &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
                    {
                        _filterString += _groupByColumnNames[j] + &lt;span class=&quot;str&quot;&gt;&quot; = &#39;&quot;&lt;/span&gt; + _dtReturn.Rows[i][_groupByColumnNames[j]].ToString() + &lt;span class=&quot;str&quot;&gt;&quot;&#39;&quot;&lt;/span&gt;;
                    }
                }
                &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

                &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Compute the aggregate command

                &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (DataTableAggregateFunction _calculatedField &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _fieldsForCalculation)
                {
                    _dtReturn.Rows[i][_calculatedField.OutPutColumnName] = _dtSource.Compute(_calculatedField.enmFunction.ToString() + &lt;span class=&quot;str&quot;&gt;&quot;(&quot;&lt;/span&gt; + _calculatedField.ColumnName + &lt;span class=&quot;str&quot;&gt;&quot;)&quot;&lt;/span&gt;, _filterString);
                }
                
                &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
            }

            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _dtReturn;
        }
    }
}
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;How to Use?&lt;/h3&gt;
Call the function from somewhere.
&lt;pre class=&quot;csharpcode&quot;&gt;
(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SampleApplication.Helper()).DemoGroupBy();&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Screenshot&lt;/h3&gt;
Before Group By :
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguqxqojoFo1svWcHi-LwXjSzktcQFSufBhVp2569PEugN143ygpNt-sEnQpV-RFMDtRD5E5nETP-bO-9ZacB0FyUQzSg6qwWxy28qV0zaM0zy50xM5ns2Hdfa1EFSlA0H6jR1zjkB5nA/s1600/Pic1.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;210&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguqxqojoFo1svWcHi-LwXjSzktcQFSufBhVp2569PEugN143ygpNt-sEnQpV-RFMDtRD5E5nETP-bO-9ZacB0FyUQzSg6qwWxy28qV0zaM0zy50xM5ns2Hdfa1EFSlA0H6jR1zjkB5nA/s320/Pic1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

After Group By :
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4EFMhBJhp9M59Y9NvJLxaN7F-HAExf6f-Yhqm76eDm9pRlUzI0aQmZdrtblEt9e4i255Z31W_hvYuIdvFdyC2VWxILMfkwzs4jtPUDP6sTf8MfARLWpk58Q0QR0g8K8dwy9sgD1ELjw/s1600/Pic2.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4EFMhBJhp9M59Y9NvJLxaN7F-HAExf6f-Yhqm76eDm9pRlUzI0aQmZdrtblEt9e4i255Z31W_hvYuIdvFdyC2VWxILMfkwzs4jtPUDP6sTf8MfARLWpk58Q0QR0g8K8dwy9sgD1ELjw/s320/Pic2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Please let me know if this helped.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/4165017982029799805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/apply-multiple-column-group-by-on.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/4165017982029799805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/4165017982029799805'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/apply-multiple-column-group-by-on.html' title='Apply &quot;Multiple&quot; column Group By on DataTable in C#'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguqxqojoFo1svWcHi-LwXjSzktcQFSufBhVp2569PEugN143ygpNt-sEnQpV-RFMDtRD5E5nETP-bO-9ZacB0FyUQzSg6qwWxy28qV0zaM0zy50xM5ns2Hdfa1EFSlA0H6jR1zjkB5nA/s72-c/Pic1.png" height="72" width="72"/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-702137488201016853</id><published>2012-05-17T16:27:00.000+05:30</published><updated>2012-05-17T16:27:14.722+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="PeopleEditor"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="WebPart"/><title type='text'>SharePoint 2010 : Placing the SharePoint:PeopleEditor icons on right instead of bottom.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
The SharePoint:PeopleEditor show the icons on the right side instead of bottom.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Sample Page : ASPX&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;style&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        .ppimg{border: 0px;vertical-align: middle !important;}
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;br&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;cellpadding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;10&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;cellspacing&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;5&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;border:1px solid #808080&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;colspan&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;2&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;People picker on right instead of bottom&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                Default
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;SharePoint:PeopleEditor&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowEmpty&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ValidatorEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ppDefault&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowCreateButtonInActiveDirectoryAccountCreationMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;SelectionSet&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;User,SPGroup&quot;&lt;/span&gt;
                    &lt;span class=&quot;attr&quot;&gt;Rows&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;300px&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;nowrap&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;nowrap&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                Custom View
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;SharePoint:PeopleEditor&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;AllowEmpty&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ValidatorEnabled&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ppCustom&quot;&lt;/span&gt;
                                &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowCreateButtonInActiveDirectoryAccountCreationMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;SelectionSet&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;User,SPGroup&quot;&lt;/span&gt;
                                &lt;span class=&quot;attr&quot;&gt;Rows&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Width&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;300px&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ShowButtons&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;valign&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;top&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aPPChekNames&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Check Name&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;/_layouts/images/checknames.png&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Check Names&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ppimg&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;valign&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;top&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;aPPBrowse&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Browse&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;/_layouts/images/addressbook.gif&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Browse&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ppimg&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;tr&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Sample Page : Code&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;//Apply the Javascript to the Icons&lt;/span&gt;
aPPChekNames.Attributes.Add(&lt;span class=&quot;str&quot;&gt;&quot;onclick&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;if(!ValidatePickerControl(&#39;&quot;&lt;/span&gt; + ppCustom.ClientID + &lt;span class=&quot;str&quot;&gt;&quot;&#39;)){ ShowValidationError(); return false;} var arg=getUplevel(&#39;&quot;&lt;/span&gt; + ppCustom.ClientID + &lt;span class=&quot;str&quot;&gt;&quot;&#39;); var ctx=&#39;&quot;&lt;/span&gt; + ppCustom.ClientID + &lt;span class=&quot;str&quot;&gt;&quot;&#39;;EntityEditorSetWaitCursor(ctx);WebForm_DoCallback(&#39;&quot;&lt;/span&gt; + ppCustom.UniqueID + &lt;span class=&quot;str&quot;&gt;&quot;&#39;,arg,EntityEditorHandleCheckNameResult,ctx,EntityEditorHandleCheckNameError,true);return false;&quot;&lt;/span&gt;);
aPPBrowse.Attributes.Add(&lt;span class=&quot;str&quot;&gt;&quot;onclick&quot;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&quot;javascript:__Dialog__&quot;&lt;/span&gt; + ppCustom.ClientID + &lt;span class=&quot;str&quot;&gt;&quot;(); return false;&quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Result&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG83A_WABJcd-b2_VIdIthKYdQ54N9s06aF8ruaQlHebkEfz2Og-ZJmWyoGJsc0LN8L_Aif0Wlx8ANcD6bq4Db6t1DWfkhBIxsp5cGCCfS5aoGxaX8zCO4EXA1_DNJV25_IbvcEqOOWQ/s1600/DifferencePicture.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;114&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG83A_WABJcd-b2_VIdIthKYdQ54N9s06aF8ruaQlHebkEfz2Og-ZJmWyoGJsc0LN8L_Aif0Wlx8ANcD6bq4Db6t1DWfkhBIxsp5cGCCfS5aoGxaX8zCO4EXA1_DNJV25_IbvcEqOOWQ/s320/DifferencePicture.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I am not sure if many know about this or this is normal, but just wanted to share. Let me know if this helped.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/702137488201016853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-placing.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/702137488201016853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/702137488201016853'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-placing.html' title='SharePoint 2010 : Placing the SharePoint:PeopleEditor icons on right instead of bottom.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG83A_WABJcd-b2_VIdIthKYdQ54N9s06aF8ruaQlHebkEfz2Og-ZJmWyoGJsc0LN8L_Aif0Wlx8ANcD6bq4Db6t1DWfkhBIxsp5cGCCfS5aoGxaX8zCO4EXA1_DNJV25_IbvcEqOOWQ/s72-c/DifferencePicture.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-725126412858928071</id><published>2012-05-17T16:13:00.000+05:30</published><updated>2012-05-22T18:44:05.113+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="XSL"/><category scheme="http://www.blogger.com/atom/ns#" term="XSLTStyleSheet"/><title type='text'>SharePoint 2010 : Call server side function from XSL.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
To use a server side function from a XSL used in a web part.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
It is simple to use a server side function. Just need to make sure the dll should be deployed in GAC. In this example I created a class with name &quot;ClassName&quot;, the project name is &quot;SampleApplication&quot;. Deployed the dll in GAC. Modify the XSL head and add &lt;b&gt;xmlns:helper=&quot;SampleApplication.ClassName&quot;&lt;/b&gt; on the head. &quot;helper&quot; is like an tag which will point to the class.
&lt;br /&gt;
&lt;br /&gt;
&lt;h5&gt;XSL&lt;/h5&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xsl:stylesheet&lt;/span&gt; 
  &lt;span class=&quot;attr&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1.0&quot;&lt;/span&gt; 
  &lt;span class=&quot;attr&quot;&gt;exclude-result-prefixes&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;x d xsl msxsl cmswrt helper&quot;&lt;/span&gt;
  &lt;span class=&quot;attr&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/2001/XMLSchema&quot;&lt;/span&gt; 
  &lt;span class=&quot;attr&quot;&gt;xmlns:d&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/sharepoint/dsp&quot;&lt;/span&gt; 
  &lt;span class=&quot;attr&quot;&gt;xmlns:ddwrt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/WebParts/v2/DataView/runtime&quot;&lt;/span&gt;
  &lt;span class=&quot;attr&quot;&gt;xmlns:cmswrt&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/WebParts/v3/Publishing/runtime&quot;&lt;/span&gt;
  &lt;span class=&quot;attr&quot;&gt;xmlns:xsl&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://www.w3.org/1999/XSL/Transform&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns:msxsl&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;urn:schemas-microsoft-com:xslt&quot;&lt;/span&gt;
  &lt;span class=&quot;attr&quot;&gt;xmlns:helper&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SampleApplication.ClassName&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h5&gt;SampleApplication.ClassName&lt;/h5&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; SampleApplication
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; ClassName
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Properties
        
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Name &lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; Name = &lt;span class=&quot;str&quot;&gt;&quot;Maulik Dhorajia&quot;&lt;/span&gt;;
        
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Today Date&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; TodayDate = System.DateTime.Now.ToString();

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Gets the property&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;propertyKey&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; GetProperty(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; propertyKey)
        {
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propertyKey == &lt;span class=&quot;str&quot;&gt;&quot;Name&quot;&lt;/span&gt;)
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Name;
            }
            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (propertyKey == &lt;span class=&quot;str&quot;&gt;&quot;TodayDate&quot;&lt;/span&gt;)
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; TodayDate;
            }
            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; 
            {
                &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
            }
        }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h5&gt;Calling the function from XSL&lt;/h5&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xsl:value-of&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;helper:GetLabel(&#39;Name&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xsl:value-of&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;helper:GetLabel(&#39;TodayDate&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This should be all to show the stuff on the page. Let me know if this helped.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/725126412858928071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-call-server-side.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/725126412858928071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/725126412858928071'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-call-server-side.html' title='SharePoint 2010 : Call server side function from XSL.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5239981710186337484</id><published>2012-05-16T15:46:00.001+05:30</published><updated>2012-05-16T15:46:48.048+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Content Type"/><category scheme="http://www.blogger.com/atom/ns#" term="Document Library"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint Ribbon"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><title type='text'>SharePoint 2010 : Insert custom icon in a custom group on Ribbon of Document Library.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
Insert a custom icon(Email icon) on the SharePoint Document Library. The Icon should show in a Custom Group.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Challange&lt;/h3&gt;
I thought getting the Icon on the top was easy(actually it was easy to place an icon on the top). But to place the icon in a Custom Group was a bit tough that it seems.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Follow the steps to achieve&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open Visual Studio 2010, Create an empty SharePoint Application.&lt;/li&gt;
&lt;li&gt;Add a Module, Edit the Element.xml
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;xml&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;utf-8&quot;&lt;/span&gt;?&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Elements&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;http://schemas.microsoft.com/sharepoint/&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CustomAction&lt;/span&gt;
      &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustom&quot;&lt;/span&gt;
      &lt;span class=&quot;attr&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;CommandUI.Ribbon&quot;&lt;/span&gt;
      &lt;span class=&quot;attr&quot;&gt;RegistrationType&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ContentType&quot;&lt;/span&gt;
      &lt;span class=&quot;attr&quot;&gt;RegistrationId&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;0x01&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIExtension&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Ribbon.Documents.Groups._children&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Group&lt;/span&gt;
              &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroup&quot;&lt;/span&gt;
              &lt;span class=&quot;attr&quot;&gt;Sequence&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;100&quot;&lt;/span&gt;
              &lt;span class=&quot;attr&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;E-Mail Controls&quot;&lt;/span&gt;
              &lt;span class=&quot;attr&quot;&gt;Title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;E-Mail Controls&quot;&lt;/span&gt;
              &lt;span class=&quot;attr&quot;&gt;Template&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroupTemplate&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Controls&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroupControl&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
              &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Button&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroupControlButton&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;Sequence&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;5&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleAlert&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;Image32by32&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;/_layouts/1033/images/formatmap32x32.png&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Image32by32Left&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;-448&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Image32by32Top&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;-128&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;ToolTipTitle&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Email Documents&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;ToolTipDescription&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Select the documents which you want to email!&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;LabelText&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Email Selected Documents&quot;&lt;/span&gt;
                  &lt;span class=&quot;attr&quot;&gt;TemplateAlias&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;o1&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Controls&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Ribbon.Templates._children&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;GroupTemplate&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroupTemplate&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Title&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LargeLarge&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
              &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;OverflowSection&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;OneRow&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;TemplateAlias&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;o1&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DisplayMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Large&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
              &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;OverflowSection&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;OneRow&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;TemplateAlias&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;o2&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;DisplayMode&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Large&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;GroupTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Ribbon.Documents.Scaling._children&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;MaxSize&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Ribbon.Documents.Scaling.Custom.MaxSize&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Sequence&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;15&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;GroupId&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailDocsCustomGroup&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Size&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;LargeLarge&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinition&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIDefinitions&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIHandlers&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIHandler&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;SimpleAlert&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;CommandAction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript:OpenEmailPage();&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIHandlers&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CommandUIExtension&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CustomAction&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;CustomAction&lt;/span&gt;
   &lt;span class=&quot;attr&quot;&gt;Id&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;EmailRelatedScript&quot;&lt;/span&gt;
   &lt;span class=&quot;attr&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ScriptLink&quot;&lt;/span&gt;
   &lt;span class=&quot;attr&quot;&gt;ScriptSrc&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;=&quot;/_layouts/WhatEvePathYouHave/EmailScript.js&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
  
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;Elements&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Place the EmailScript.js at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\WhatEvePathYouHave(You can map the folder and do this). With the help of this script you can do manipulations on the click of the icon placed on the top ribbon. Below is the script in EmailScript.js.
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;//Get the current user and add the values found in the Email settings list&lt;/span&gt;
function OpenEmailPage() {

    &lt;span class=&quot;rem&quot;&gt;//Gets the current Context&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _ctx = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SP.ClientContext.get_current();
    &lt;span class=&quot;rem&quot;&gt;//Selected Items Variables&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _itemIds = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
    &lt;span class=&quot;rem&quot;&gt;//Get current list id&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _listId = SP.ListOperation.Selection.getSelectedList();
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _listUrl = window.location.href;
    &lt;span class=&quot;rem&quot;&gt;//get all selected list items&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _selectedItems = SP.ListOperation.Selection.getSelectedItems(_ctx);
    &lt;span class=&quot;rem&quot;&gt;//collect selected item ids&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; i = 0; i &amp;lt; _selectedItems.length; i++) {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_itemIds == &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;)
        { _itemIds += _selectedItems[i].id; }
        &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
        { _itemIds += &lt;span class=&quot;str&quot;&gt;&quot;,&quot;&lt;/span&gt; + _selectedItems[i].id; }
    }

    alert(&lt;span class=&quot;str&quot;&gt;&#39;ListID = &#39;&lt;/span&gt; + _listId + &lt;span class=&quot;str&quot;&gt;&quot;\nListUrl = &quot;&lt;/span&gt; + _listUrl + &lt;span class=&quot;str&quot;&gt;&quot;\nIDs=&quot;&lt;/span&gt; + _itemIds);    
}&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Before deploying the solution, check a document library. The ribbon on the top in the documents should like the below given image.&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM50ZId3h7IHI3lclQUMTLZhIEL5TPrHGpXbtFIlgsQa8jYfW7JTsML5Ve2AWIoq93TfQO5_LaD97rUotspaQK_mEZAHxUZddvUldrgqsinC-6H2BQ-xNaA0O9dV3XoCmmB44boVnN8g/s1600/Before.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;75&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM50ZId3h7IHI3lclQUMTLZhIEL5TPrHGpXbtFIlgsQa8jYfW7JTsML5Ve2AWIoq93TfQO5_LaD97rUotspaQK_mEZAHxUZddvUldrgqsinC-6H2BQ-xNaA0O9dV3XoCmmB44boVnN8g/s320/Before.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Deploy the solution. Visit a Document Library, select docs and the new Icon should show up on the top right corner.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizETBnHSZc0NxSSS-rnm3mUtnV_iXBqgvuk0kJk-4U3fzmUySOj5sJ9MhNnNck6feFJxDND5BuAC-dFkcrhnEZryIL4OTf38LFbtsQ2v5Rgdh9ySishyphenhyphenyQmK6Bh5iSTMsZ8G0YmfkF5g/s1600/After.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;139&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizETBnHSZc0NxSSS-rnm3mUtnV_iXBqgvuk0kJk-4U3fzmUySOj5sJ9MhNnNck6feFJxDND5BuAC-dFkcrhnEZryIL4OTf38LFbtsQ2v5Rgdh9ySishyphenhyphenyQmK6Bh5iSTMsZ8G0YmfkF5g/s320/After.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

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

I am not very good with Ribbons and spent a lot of time to get just this portion. So thought if this can help many other who dont have time and have to get this quickly.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5239981710186337484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-insert-custom-icon-in.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5239981710186337484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5239981710186337484'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/05/sharepoint-2010-insert-custom-icon-in.html' title='SharePoint 2010 : Insert custom icon in a custom group on Ribbon of Document Library.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM50ZId3h7IHI3lclQUMTLZhIEL5TPrHGpXbtFIlgsQa8jYfW7JTsML5Ve2AWIoq93TfQO5_LaD97rUotspaQK_mEZAHxUZddvUldrgqsinC-6H2BQ-xNaA0O9dV3XoCmmB44boVnN8g/s72-c/Before.png" height="72" width="72"/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-863356824204732520</id><published>2012-04-06T20:54:00.000+05:30</published><updated>2012-04-06T20:54:56.175+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Multilingual Site"/><category scheme="http://www.blogger.com/atom/ns#" term="Resource File"/><category scheme="http://www.blogger.com/atom/ns#" term="resx"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Variation"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Web Part"/><title type='text'>SharePoint 2010 : Use Resouce(resx) file in a Multilingual site.</title><content type='html'>&lt;h1&gt;Goal&lt;/h1&gt;
Our site is created using variations in both English and Spanish. Create a Visual Web Part which can use the resource file(.resx) to show different texts for different language.&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;Steps to achieve goal&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Create a SharePoint project with name &quot;Sample&quot;.&lt;/li&gt;
&lt;li&gt;Add a web part with name &quot;SampleWebPart&quot;.&lt;/li&gt;
&lt;li&gt;Add a &quot;Mapped Folder&quot; to &quot;Resources&quot;. 2 files needs to be added.
&lt;ol&gt;
&lt;li&gt;SampleWebPart.en-US.resx - English version resource file. Add some text to the resource.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN1p8_mz7JqPWaNvo2oLr_uFbnnwg_g9W5aAhb_nfCTGuGTgtORdXde7MEMM0yVZVMc6oaWia0IS0_cYfLZDPVQea5XMSidSgW08-dxcgIcwFA8VfjCmNtcRZAfPnRGrldpH7IOtuLvw/s1600/en-US.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;106&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN1p8_mz7JqPWaNvo2oLr_uFbnnwg_g9W5aAhb_nfCTGuGTgtORdXde7MEMM0yVZVMc6oaWia0IS0_cYfLZDPVQea5XMSidSgW08-dxcgIcwFA8VfjCmNtcRZAfPnRGrldpH7IOtuLvw/s320/en-US.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;li&gt;SampleWebPart.es-ES.resx - Spanish version resource file. Add some text to the resource.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirtKMgqDWs2fkqogasO0hISFzx31CkKSwsm93a2Ub9iSpXj-KCGYWOJtJtG6bYInAsO5QFefSJGR9E1d5oKQulURmWtWPbzS4S0z1TJVwy72R91aFMQMn_0R_NhT6fMpagkYwFqZzbLw/s1600/es-ES.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;111&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirtKMgqDWs2fkqogasO0hISFzx31CkKSwsm93a2Ub9iSpXj-KCGYWOJtJtG6bYInAsO5QFefSJGR9E1d5oKQulURmWtWPbzS4S0z1TJVwy72R91aFMQMn_0R_NhT6fMpagkYwFqZzbLw/s320/es-ES.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;At this point the project &quot;Solution Explorer&quot; will look like
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0_V8j0x1p17nC3WoptK0G11GAChUrNaM33eIm72jfSJBGWf-F92A71pnmVo5LzutcYLkBnIBLSEbR4QeqRsTaUkj26PcRnorDrA6m8ibZvfZ26ToOggZg1o_tOQf2T2eGbFBRk9pzTw/s1600/Img1.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;289&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0_V8j0x1p17nC3WoptK0G11GAChUrNaM33eIm72jfSJBGWf-F92A71pnmVo5LzutcYLkBnIBLSEbR4QeqRsTaUkj26PcRnorDrA6m8ibZvfZ26ToOggZg1o_tOQf2T2eGbFBRk9pzTw/s320/Img1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;For applying the resource, Open the Feature1 properties. And make the 2 changes shown in the below given image.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyj0PdJOKBFOLsqiMmIK7CdljiTLFxwAMgv4T8x6UZNESpkHhQjfh84RHvyvf6E2lfCITmzSdH7SgM7gycmmC0R53kIi7BySjPhCJmZTVWw2Lyr16-P2aqySJSDmGQAEe3AX__xllamw/s1600/Img2.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;114&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyj0PdJOKBFOLsqiMmIK7CdljiTLFxwAMgv4T8x6UZNESpkHhQjfh84RHvyvf6E2lfCITmzSdH7SgM7gycmmC0R53kIi7BySjPhCJmZTVWw2Lyr16-P2aqySJSDmGQAEe3AX__xllamw/s320/Img2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Use the HTML and C# Code below.&lt;/li&gt;
&lt;li&gt;Once the above given steps are done, deploy the web part and They will display as below given image.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1zpvrel6rEDje6JC2xRCMkijVuV7iAyWpzjQCCocCemR0y7hmjD68wATTLpIhxkZr7v-u1TyzzxiPFK9h0EOGI_V3VCUnUP2NOuj1Y0TSVO61UWfeqzYNbuvSiz23go5hjxZ3uIalEw/s1600/Display1.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;70&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1zpvrel6rEDje6JC2xRCMkijVuV7iAyWpzjQCCocCemR0y7hmjD68wATTLpIhxkZr7v-u1TyzzxiPFK9h0EOGI_V3VCUnUP2NOuj1Y0TSVO61UWfeqzYNbuvSiz23go5hjxZ3uIalEw/s320/Display1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio3MtTy2k1n_Wn2iLYf0MAcmT5gOvhNSfxpLS7qsETYUP35lpQbsG5whgTAAEWE6Ji_Lvq5uzsksHu4taH3pRFLs2D8-sm7WcQlJcf7VUOM0hpi794jjJKU00e3UHLNgDHq5snptkaBw/s1600/Display2.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;83&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio3MtTy2k1n_Wn2iLYf0MAcmT5gOvhNSfxpLS7qsETYUP35lpQbsG5whgTAAEWE6Ji_Lvq5uzsksHu4taH3pRFLs2D8-sm7WcQlJcf7VUOM0hpi794jjJKU00e3UHLNgDHq5snptkaBw/s320/Display2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;HTML - SampleWebPartUserControl.ascx&lt;/h1&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Literal&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ltrlTitle&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;hr&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Literal&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;ltrlDescription&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;C# - SampleWebPartUserControl.ascx.cs&lt;/h1&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; System
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Sample.SampleWebPart
{
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// Simple example to use Resouce file with English/Spanish language.&lt;/span&gt;
    &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SampleWebPartUserControl : UserControl
    {
        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Events

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Page Load&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            ltrlTitle.Text = LoadResource( ResourceName.Title );
            ltrlDescription.Text = LoadResource(ResourceName.Description);
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;

        &lt;span class=&quot;preproc&quot;&gt;#region&lt;/span&gt; Resource Reader

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Name for the Version to be considered.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// NOTE :- Use exactly same &quot;Name&quot; as used in Resource(resx) file.&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; ResourceName
        { 
            Title,
            Description
        }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Gets the text on the basis of &quot;Name&quot; in Resource(resx).&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; LoadResource(ResourceName _resName)
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString(&lt;span class=&quot;str&quot;&gt;&quot;$Resources:&quot;&lt;/span&gt; + _resName.ToString(),
                &lt;span class=&quot;str&quot;&gt;&quot;SampleWebPart&quot;&lt;/span&gt;
            , (&lt;span class=&quot;kwrd&quot;&gt;uint&lt;/span&gt;)System.Globalization.CultureInfo.CurrentUICulture.LCID); 
        }

        &lt;span class=&quot;preproc&quot;&gt;#endregion&lt;/span&gt;
    }
}&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h1&gt;Happy Coding&lt;/h1&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/863356824204732520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/04/sharepoint-2010-use-resouceresx-file-in.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/863356824204732520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/863356824204732520'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/04/sharepoint-2010-use-resouceresx-file-in.html' title='SharePoint 2010 : Use Resouce(resx) file in a Multilingual site.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN1p8_mz7JqPWaNvo2oLr_uFbnnwg_g9W5aAhb_nfCTGuGTgtORdXde7MEMM0yVZVMc6oaWia0IS0_cYfLZDPVQea5XMSidSgW08-dxcgIcwFA8VfjCmNtcRZAfPnRGrldpH7IOtuLvw/s72-c/en-US.png" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-3577256075802023713</id><published>2012-04-06T18:49:00.000+05:30</published><updated>2012-04-06T18:49:12.453+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Get all properties of Object using Javascript.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
Assuming we are working on an a task. On a process we get an object. We don&#39;t know what exactly is there in the object or what properties the object is having. The javascript mentioned will print the list of properties of an object.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;javascript&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;       
    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _jsonObject = {&lt;span class=&quot;str&quot;&gt;&quot;Property1&quot;&lt;/span&gt;:1,&lt;span class=&quot;str&quot;&gt;&quot;Property2&quot;&lt;/span&gt;:&lt;span class=&quot;str&quot;&gt;&quot;Simple String&quot;&lt;/span&gt;,&lt;span class=&quot;str&quot;&gt;&quot;Property3&quot;&lt;/span&gt;:&lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;};
    alert(_jsonObject);

    &lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; _html = &lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;kwrd&quot;&gt;var&lt;/span&gt; key &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _jsonObject) {
        _html = _html + key + &lt;span class=&quot;str&quot;&gt;&quot; : &quot;&lt;/span&gt; + _jsonObject[key] + &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;br /&amp;gt;&quot;&lt;/span&gt; ;
    }
    document.writeln(_html);
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Output&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjddwcVkjZCl73sxuDNy7W3i7Bau-5f_YcXwZhGPr6-pPFcI-aV9hcS-jKc3LUdpHuZg9YtEDbga0gi-dp4QTWKXzXfbJzeBtqwurqYspMR33uSHFLb14SFtHKy2Ar15bcLLQvy_JBxkg/s1600/Output.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;86&quot; width=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjddwcVkjZCl73sxuDNy7W3i7Bau-5f_YcXwZhGPr6-pPFcI-aV9hcS-jKc3LUdpHuZg9YtEDbga0gi-dp4QTWKXzXfbJzeBtqwurqYspMR33uSHFLb14SFtHKy2Ar15bcLLQvy_JBxkg/s320/Output.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/3577256075802023713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/04/get-all-properties-of-object-using.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3577256075802023713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3577256075802023713'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/04/get-all-properties-of-object-using.html' title='Get all properties of Object using Javascript.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjddwcVkjZCl73sxuDNy7W3i7Bau-5f_YcXwZhGPr6-pPFcI-aV9hcS-jKc3LUdpHuZg9YtEDbga0gi-dp4QTWKXzXfbJzeBtqwurqYspMR33uSHFLb14SFtHKy2Ar15bcLLQvy_JBxkg/s72-c/Output.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-3070131463908196146</id><published>2012-03-03T15:25:00.000+05:30</published><updated>2012-03-03T15:31:32.728+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Error"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><title type='text'>SharePoint 2010 Error Solution : A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.</title><content type='html'>&lt;h3&gt;Introduction&lt;/h3&gt;
An occours when a user tries to add a webpart on the page. The description of the error is &quot;&lt;i&gt;A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.&lt;/i&gt;&quot;.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJKKYaUY_vMGKwOkZhloO9YUO9X0Abm5ZnHXLHh6M8D1jSe8eVjAr8FnD7FXLf8f1lg52ggCjb_VCKTcDSTQxcvu1TVzwlgCkUxaw6vZTzeNMwFdYivGvs88BOvUdIrqc9psEWY5TSQ/s1600/Error.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;118&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJKKYaUY_vMGKwOkZhloO9YUO9X0Abm5ZnHXLHh6M8D1jSe8eVjAr8FnD7FXLf8f1lg52ggCjb_VCKTcDSTQxcvu1TVzwlgCkUxaw6vZTzeNMwFdYivGvs88BOvUdIrqc9psEWY5TSQ/s320/Error.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Test Cases&lt;/h3&gt;
Here, I am creating a small solution to show why I got this issue.
&lt;ol&gt;
    &lt;li&gt;Open Visual Studio 2010. Create a project with name &quot;Sample&quot;.&lt;/li&gt;
    &lt;li&gt;Add a WebPart to the project with name &quot;SomeWebPart&quot;(Note : Mind it WebPart not VisualWebPart).&lt;/li&gt;
    &lt;li&gt;Add a class library to the solution with name &quot;Helper&quot;.&lt;/li&gt;
    &lt;li&gt;Add a &quot;Helper.snk&quot; to the project by Right Clicking &quot;Helper&quot; &gt; Properties &gt; Signing &gt; Choose a strong name...&lt;/li&gt;
    &lt;li&gt;Once that is done the structure will look like image given below&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjstt2IuEkNq5eF3yFcBqDiIbcKnZx5jYJTTN8CgTM_aL2Gnc586Ttre2w0aInzRs9JC9HgIzprES9WBzbfhj5DxiCBjQSqgcI9cQZpfR5Q6VCbWgvQbnUlkYVG2HCsuhdoNhphnzzqXg/s1600/SolutionExlorer.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;194&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjstt2IuEkNq5eF3yFcBqDiIbcKnZx5jYJTTN8CgTM_aL2Gnc586Ttre2w0aInzRs9JC9HgIzprES9WBzbfhj5DxiCBjQSqgcI9cQZpfR5Q6VCbWgvQbnUlkYVG2HCsuhdoNhphnzzqXg/s320/SolutionExlorer.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;Helper.Enums Code&lt;/b&gt;&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Linq;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Text;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Helper
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; Enums
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;enum&lt;/span&gt; SomeType
        {
            A = 0,
            B = 1,
            C = 2
        }
    }
}
&lt;/pre&gt;&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;SomeWebPart.cs Code&lt;/b&gt;&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.ComponentModel;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; System.Web.UI.WebControls.WebParts;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.WebControls;

&lt;span class=&quot;kwrd&quot;&gt;namespace&lt;/span&gt; Sample.SomeWebPart
{
    [ToolboxItemAttribute(&lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;)]
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; SomeWebPart : WebPart
    {
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// The enum which resides in enum&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Helper.Enums.SomeType SomeTypeEnum { &lt;span class=&quot;kwrd&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;kwrd&quot;&gt;set&lt;/span&gt;; }

        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// Create child control&lt;/span&gt;
        &lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; CreateChildControls()
        {

        }       
        
    }
}&lt;/pre&gt;&lt;/li&gt;
    &lt;li&gt;Deploy to the site. Try adding the WebPart and it will give the above mentioned error.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Problem&lt;/h3&gt;
The problem is &quot;Sample.dll&quot; created for the WebPart gets added to the wsp and gets added to GAC automatically but the &quot;Helper.dll&quot; is not considered as a safe one and it stays out of GAC and so while adding the WebPart, it blows and the error shows on the alert window.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;ol&gt;
    &lt;li&gt;&lt;b&gt;Sample&lt;/b&gt; &gt; &lt;b&gt;Package&lt;/b&gt; &gt; Open &quot;&lt;b&gt;Package.package&lt;/b&gt;&quot;&lt;/li&gt;
    &lt;li&gt;At the bottom you will find an option title &quot;Advanced&quot;.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqilFYlUtz11DBIJAZq0jmXoiOkd344vA-exuqQeMTP-KVetJjW8zA2egR3w35ih38srj6gwq7Xsph-r7GuQPBEGIdRtpZeLwE19bZtYrFmu5vpL_SL4n0tRVd_0cjtDLveLUVubWhyphenhyphenA/s1600/02.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqilFYlUtz11DBIJAZq0jmXoiOkd344vA-exuqQeMTP-KVetJjW8zA2egR3w35ih38srj6gwq7Xsph-r7GuQPBEGIdRtpZeLwE19bZtYrFmu5vpL_SL4n0tRVd_0cjtDLveLUVubWhyphenhyphenA/s320/02.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/li&gt;
    &lt;li&gt;As shown in the image select &quot;&lt;b&gt;Add Assembly from Project Output...&lt;/b&gt;&quot;.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCWSmBhxO6ozZJ1NK0s8fCeZV5WDChr8WDL_FHmF7SJ_LxwD4-Qqs7Nubnygws_HcQl8VHC5ePi3iyJhTB83PWS02DYcN742ihFwDx5RsizXmpmP-HtMBA91hRCDCEvdp772qxQ026MQ/s1600/03.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCWSmBhxO6ozZJ1NK0s8fCeZV5WDChr8WDL_FHmF7SJ_LxwD4-Qqs7Nubnygws_HcQl8VHC5ePi3iyJhTB83PWS02DYcN742ihFwDx5RsizXmpmP-HtMBA91hRCDCEvdp772qxQ026MQ/s320/03.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/li&gt;
    &lt;li&gt;In the dialog select &quot;Helper&quot; will auto populate the Helper details.&lt;/li&gt;
    &lt;li&gt;&lt;b&gt;Safe Controls&lt;/b&gt; section add a new item.&lt;/li&gt;
    &lt;li&gt;Fill the Namespace and Assembly with name &quot;Helper&quot;.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXtDhnL0_Z8kZsyKYXXbhwXmqLJC9P1XmSn3uocd7fEFFZ_JmxrwPERaZxe0SGRWwDTVxorMZOEThD7BsR7haYFNQk2AkvjgP_jzZAF-TopWAPVPA6xB5r4plr8MhrlzYnH_g_yXO79w/s1600/04.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXtDhnL0_Z8kZsyKYXXbhwXmqLJC9P1XmSn3uocd7fEFFZ_JmxrwPERaZxe0SGRWwDTVxorMZOEThD7BsR7haYFNQk2AkvjgP_jzZAF-TopWAPVPA6xB5r4plr8MhrlzYnH_g_yXO79w/s320/04.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
    &lt;li&gt;Click &quot;&lt;b&gt;OK&lt;/b&gt;&quot; and exit the dialog. You can see the settings of Helper added on the Advanced screen.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_VTwVNj6iEvpTirgV4j3XbMq36QdqqnKSXFI0Fpvoba-XMDpuolKFkIfhkAXVUaWQCmjSngJ1ClqpbjQ0PWIZWZU2bw2YRtny0m12DfPTYuaGV83xNsSmVlHwPihTF35HKtqhNIOgbg/s1600/05.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;51&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_VTwVNj6iEvpTirgV4j3XbMq36QdqqnKSXFI0Fpvoba-XMDpuolKFkIfhkAXVUaWQCmjSngJ1ClqpbjQ0PWIZWZU2bw2YRtny0m12DfPTYuaGV83xNsSmVlHwPihTF35HKtqhNIOgbg/s320/05.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/li&gt;
    &lt;li&gt;Deploy the WebPart and try adding it again. It should work.&lt;/li&gt;    
&lt;/ol&gt;
&lt;br /&gt;&lt;br /&gt;
Hope this helped!</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/3070131463908196146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/03/sharepoint-2010-error-solution-web-part.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3070131463908196146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/3070131463908196146'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/03/sharepoint-2010-error-solution-web-part.html' title='SharePoint 2010 Error Solution : A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJKKYaUY_vMGKwOkZhloO9YUO9X0Abm5ZnHXLHh6M8D1jSe8eVjAr8FnD7FXLf8f1lg52ggCjb_VCKTcDSTQxcvu1TVzwlgCkUxaw6vZTzeNMwFdYivGvs88BOvUdIrqc9psEWY5TSQ/s72-c/Error.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-806721196903565158</id><published>2012-03-03T10:37:00.001+05:30</published><updated>2012-03-03T10:37:18.791+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="ListViewWebPart"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="WebPart"/><title type='text'>SharePoint 2010 : Remove a WebPart from Page programmatically using C#.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
To remove webparts from a page programmatically using C#.
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// This function will remove web parts with title passed&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_web&quot;&amp;gt;Web object&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_pageUrl&quot;&amp;gt;The url of the page on which the web part exists.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;/// &amp;lt;param name=&quot;_title&quot;&amp;gt;The title of the Web part&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; RemoveWebPart(SPWeb _web, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _pageUrl, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _webPartTitle)
{
    &lt;span class=&quot;rem&quot;&gt;//Remove the control once the page is copied&lt;/span&gt;
    Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager _webPartCollection = _web.GetLimitedWebPartManager(_pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

    &lt;span class=&quot;rem&quot;&gt;//Retrive the webpart and remove&lt;/span&gt;
    IList&amp;lt;Microsoft.SharePoint.WebPartPages.WebPart&amp;gt; _listFormWebParts = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _wp &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _webPartCollection.WebParts.Cast&amp;lt;Microsoft.SharePoint.WebPartPages.WebPart&amp;gt;()
                                                                            where &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Compare( _wp.Title , _webPartTitle  , &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt; ) == 0
                                                                            select _wp).ToList();

    &lt;span class=&quot;rem&quot;&gt;//Check if there are any web parts found&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_listFormWebParts != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
    {
        &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (Microsoft.SharePoint.WebPartPages.WebPart _listFormWebPart &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _listFormWebParts)
        {
            &lt;span class=&quot;rem&quot;&gt;//Remove the webpart&lt;/span&gt;
            _webPartCollection.DeleteWebPart(_listFormWebPart);

            &lt;span class=&quot;rem&quot;&gt;//Update&lt;/span&gt;
            _web.Update();
        }
    }
}&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Tip&lt;/h3&gt;
Suppose we dont want to remove the webpart using &quot;Title&quot; we want to remove the webpart with type.
&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;//Retrive the webpart and remove&lt;/span&gt;
IList&amp;lt;Microsoft.SharePoint.WebPartPages.WebPart&amp;gt; _listFormWebParts = (&lt;span class=&quot;kwrd&quot;&gt;from&lt;/span&gt; _wp &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; _webPartCollection.WebParts.Cast&amp;lt;Microsoft.SharePoint.WebPartPages.WebPart&amp;gt;()
                                                                        where _wp.GetType() == &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(Microsoft.SharePoint.WebPartPages.ListFormWebPart)
                                                                        select _wp).ToList();&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/806721196903565158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/03/sharepoint-2010-remove-webpart-from.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/806721196903565158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/806721196903565158'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/03/sharepoint-2010-remove-webpart-from.html' title='SharePoint 2010 : Remove a WebPart from Page programmatically using C#.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-6179251843404859264</id><published>2012-02-27T19:27:00.000+05:30</published><updated>2012-02-27T19:30:41.475+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008"/><category scheme="http://www.blogger.com/atom/ns#" term="Stored Procedure"/><title type='text'>SQL Server : Sample for reading xml data</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;
Simple SQL query to fetch data from an xml.

&lt;pre class=&quot;csharpcode&quot;&gt;
&lt;span class=&quot;rem&quot;&gt;--//---------- Declare ----------//&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;DECLARE&lt;/span&gt; @xmlSample XML;

&lt;span class=&quot;kwrd&quot;&gt;SET&lt;/span&gt; @xmlSample = &lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;GUIDs&amp;gt;
  &amp;lt;GUID Temp=&quot;a&quot;&amp;gt;1&amp;lt;/GUID&amp;gt;
  &amp;lt;GUID Temp=&quot;a&quot;&amp;gt;2&amp;lt;/GUID&amp;gt;
  &amp;lt;GUID Temp=&quot;a&quot;&amp;gt;3&amp;lt;/GUID&amp;gt;
  &amp;lt;GUID Temp=&quot;b&quot;&amp;gt;4&amp;lt;/GUID&amp;gt;
  &amp;lt;GUID Temp=&quot;b&quot;&amp;gt;5&amp;lt;/GUID&amp;gt;
&amp;lt;/GUIDs&amp;gt;&#39;&lt;/span&gt;;

&lt;span class=&quot;rem&quot;&gt;--//---------- Set Query ----------//&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; 
(
    &lt;span class=&quot;kwrd&quot;&gt;SELECT&lt;/span&gt; 
        d.&lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;(&lt;span class=&quot;str&quot;&gt;&#39;.&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;INT&#39;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; GUID , 
        d.&lt;span class=&quot;kwrd&quot;&gt;value&lt;/span&gt;(&lt;span class=&quot;str&quot;&gt;&#39;@Temp&#39;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#39;VARCHAR(36)&#39;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; Temp
    &lt;span class=&quot;kwrd&quot;&gt;FROM&lt;/span&gt; @xmlSample.nodes(&lt;span class=&quot;str&quot;&gt;&#39;/GUIDs/GUID&#39;&lt;/span&gt;) d(d) 
) &lt;span class=&quot;kwrd&quot;&gt;AS&lt;/span&gt; A


&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/6179251843404859264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/goal-simple-sql-query-to-fetch-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6179251843404859264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/6179251843404859264'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/goal-simple-sql-query-to-fetch-data.html' title='SQL Server : Sample for reading xml data'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-5018608459201636810</id><published>2012-02-22T18:53:00.001+05:30</published><updated>2012-02-22T18:53:24.134+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><title type='text'>SharePoint 2010 : Login the system as Current Windows Authenticated user without code.</title><content type='html'>&lt;h3&gt;Problem&lt;/h3&gt;
Everytime I come on my SharePoint Server and open a site, I have to add my credentials to get in the site. What should be done to login default as a current user logged in Windows.&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Start Internet Explorer&lt;/li&gt;
&lt;li&gt;Security Tab&lt;/li&gt;
&lt;li&gt;Local Intranet&lt;/li&gt;
&lt;li&gt;Click &quot;Sites&quot;&lt;/li&gt;
&lt;li&gt;Click &quot;Advanced&quot;&lt;/li&gt;
&lt;li&gt;Add the local domain&lt;/li&gt;
&lt;li&gt;Save everything.&lt;/li&gt;
&lt;li&gt;Restart the browser&lt;/li&gt;
&lt;/ol&gt;

&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2g7kMsgTGF9D_NEi47r8q7R1STDC9fUheKom9-7kN1Nz31Lb-jVyi3k6IfKQYLRytqSpj8vK_jquVUqN7h9ftOmrS3YJxCpdwa5h3yySRHJuqS0qMInoXJuj3DbKbG8l-nZQuF_TGQQ/s1600/Picture.png&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;176&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2g7kMsgTGF9D_NEi47r8q7R1STDC9fUheKom9-7kN1Nz31Lb-jVyi3k6IfKQYLRytqSpj8vK_jquVUqN7h9ftOmrS3YJxCpdwa5h3yySRHJuqS0qMInoXJuj3DbKbG8l-nZQuF_TGQQ/s320/Picture.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;br /&gt;
This should take care of the issue.

&lt;br /&gt;&lt;br /&gt;
&lt;h3&gt;Important Note&lt;/h3&gt;
Mostly this is not considered as a good option, but being a developer who wants to waste time in entering the login credentials again and again. :P</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/5018608459201636810/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/sharepoint-2010-login-system-as-current.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5018608459201636810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/5018608459201636810'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/sharepoint-2010-login-system-as-current.html' title='SharePoint 2010 : Login the system as Current Windows Authenticated user without code.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2g7kMsgTGF9D_NEi47r8q7R1STDC9fUheKom9-7kN1Nz31Lb-jVyi3k6IfKQYLRytqSpj8vK_jquVUqN7h9ftOmrS3YJxCpdwa5h3yySRHJuqS0qMInoXJuj3DbKbG8l-nZQuF_TGQQ/s72-c/Picture.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-132462227700284909</id><published>2012-02-22T18:35:00.001+05:30</published><updated>2012-02-22T18:35:38.635+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ECMA"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="Master Page"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Designer 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="UpdatePanel"/><title type='text'>SharePoint 2010 : Using ECMA script recall javascript function on control click in UpdatePanel.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I dont know if this is important or not but I found this thing interesting to blog.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Goal&lt;/h3&gt;
There is a in UpdatePanel on the page. We have to call a javascript everytime the page is postback. Even if it is a postback from a control under UpdatePanel. I discovered a way using ECMA using which we can easily call the javascript function.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Solution&lt;/h3&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;!window.jQuery &amp;amp;&amp;amp; document.write(&lt;span class=&quot;str&quot;&gt;&#39;&amp;lt;script src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&#39;&lt;/span&gt;);&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;script type=&lt;span class=&quot;str&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&amp;gt;
    &lt;span class=&quot;rem&quot;&gt;//Call the function or assign the event on ready&lt;/span&gt;
    $(document).ready(&lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt;(){
        &lt;span class=&quot;rem&quot;&gt;//This will wait until script is loaded and than call our function&lt;/span&gt;
        ExecuteOrDelayUntilScriptLoaded(PageLoadEvent, &lt;span class=&quot;str&quot;&gt;&quot;sp.js&quot;&lt;/span&gt;);
    });
    
    &lt;span class=&quot;rem&quot;&gt;//This function is the most important function that will add the end request&lt;/span&gt;
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(FunctionHandler);
    
    &lt;span class=&quot;rem&quot;&gt;//Event handler that fires on the UpdatePanel control events too&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; FunctionHandler(sender, args) {
        ExecuteOrDelayUntilScriptLoaded(ButtonClickEvent, &lt;span class=&quot;str&quot;&gt;&quot;sp.js&quot;&lt;/span&gt;);
    }
    
    &lt;span class=&quot;rem&quot;&gt;//Write the time on page load&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; PageLoadEvent(){
        alert(&lt;span class=&quot;str&quot;&gt;&#39;Page Load : &#39;&lt;/span&gt; + (&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Date()).toString() );
    }

    &lt;span class=&quot;rem&quot;&gt;//Will call on button click event&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;function&lt;/span&gt; ButtonClickEvent(){
        alert(&lt;span class=&quot;str&quot;&gt;&#39;Button Click : &#39;&lt;/span&gt; + (&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Date()).toString() );
    }                
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;upPanel&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:Button&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;btn&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;attr&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;=&quot;Click here!!!&quot;&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;ContentTemplate&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;html&quot;&gt;asp:UpdatePanel&lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Important Note&lt;/h3&gt;
The most important thing in this is, if you remove &quot;&lt;i&gt;&lt;b&gt;Sys.WebForms.PageRequestManager.getInstance().add_endRequest(FunctionHandler);&lt;/b&gt;&lt;/i&gt;&quot; and try clicking the button the event wont be raised to call &quot;&lt;b&gt;&lt;i&gt;function ButtonClickEvent()&lt;/i&gt;&lt;/b&gt;&quot;. So that is the magic trick.
&lt;br /&gt;
&lt;br /&gt;
Let me know if this helped you!

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/132462227700284909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/sharepoint-2010-using-ecma-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/132462227700284909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/132462227700284909'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/02/sharepoint-2010-using-ecma-script.html' title='SharePoint 2010 : Using ECMA script recall javascript function on control click in UpdatePanel.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-9015084848734371221</id><published>2012-01-19T21:33:00.000+05:30</published><updated>2012-01-19T21:33:14.237+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><title type='text'>SharePoint 2010 - You must have manage user profiles administrator rights to use administrator mode.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;As the error metions the user should be &quot;Admin in User Profile Service&quot;. The error comes when a user try to update a profile(other user&#39;s profile). Please read my last blog for more clarification &lt;a href=&quot;http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-update-users-infomation.html&quot; alt=&quot;SharePoint 2010 - Update user&#39;s infomation using UserProfileManager programmatically.&quot;&gt;SharePoint 2010 - Update user&#39;s infomation using UserProfileManager programmatically.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Fix&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;SharePoint 2010 Central Administration&lt;/li&gt;
&lt;li&gt;Application Management &gt; Manage Service Applications&lt;/li&gt;
&lt;li&gt;Select the &quot;User Profile Service Application&quot; tab. On the top you can find an option of &quot;Administrators&quot;. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJcgCH2niQXb1pL9lPykEKaUh9vd5093q1sIjcrQ4HI6PLR4eWN3iGxDwl6LUYLXqrH_WxA7tHsH18v_0JZDWZXuEyTVsEISfbqGxq1vOZ1FNqRtC1JmhlF_9xhxJ_Vs0_oq09nzQXmQ/s1600/01.jpg&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;271&quot; width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJcgCH2niQXb1pL9lPykEKaUh9vd5093q1sIjcrQ4HI6PLR4eWN3iGxDwl6LUYLXqrH_WxA7tHsH18v_0JZDWZXuEyTVsEISfbqGxq1vOZ1FNqRtC1JmhlF_9xhxJ_Vs0_oq09nzQXmQ/s320/01.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Apply the user you are using in the Administrators and give rights to the user. I am using &quot;Administrator&quot; as a user.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisg8LgFOYewzdRlR8YbeSgdhlutUthyHZJtni4iHvUqNt6QcMO0EWs_gW6i9LY9qQhOumq44OA_NFfNrtsOc-Pq9rw9A3nrALVwV7eCgpp8ir-hq3qzkiF2UzOtiW_AC413Jvc8EedYw/s1600/02.jpg&quot; imageanchor=&quot;1&quot; style=&quot;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; width=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisg8LgFOYewzdRlR8YbeSgdhlutUthyHZJtni4iHvUqNt6QcMO0EWs_gW6i9LY9qQhOumq44OA_NFfNrtsOc-Pq9rw9A3nrALVwV7eCgpp8ir-hq3qzkiF2UzOtiW_AC413Jvc8EedYw/s320/02.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;

Let me know if this is helpfull.
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/9015084848734371221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-you-must-have-manage.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/9015084848734371221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/9015084848734371221'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-you-must-have-manage.html' title='SharePoint 2010 - You must have manage user profiles administrator rights to use administrator mode.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJcgCH2niQXb1pL9lPykEKaUh9vd5093q1sIjcrQ4HI6PLR4eWN3iGxDwl6LUYLXqrH_WxA7tHsH18v_0JZDWZXuEyTVsEISfbqGxq1vOZ1FNqRtC1JmhlF_9xhxJ_Vs0_oq09nzQXmQ/s72-c/01.jpg" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1010348719342749753.post-2877796253881130687</id><published>2012-01-19T20:46:00.000+05:30</published><updated>2012-01-19T21:34:54.187+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="CSharp"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint 2010"/><category scheme="http://www.blogger.com/atom/ns#" term="User Profile Manager"/><category scheme="http://www.blogger.com/atom/ns#" term="User Profile Service"/><title type='text'>SharePoint 2010 - Update user&#39;s infomation using UserProfileManager programmatically.</title><content type='html'>&lt;h3&gt;Goal&lt;/h3&gt;To update a user&#39;s information using C#. In the below given sample i am changing the Email(WorkEmail) of a user.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Important facts&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;User trying to update a profile should be updating own record or should be an &quot;Admin in User Profile Service&quot;. If the user is not an Admin in User Profile Service the error will come &quot;&lt;b style=&quot;color:red;&quot;&gt;&lt;i&gt;You must have manage user profiles administrator rights to use administrator mode.&lt;/i&gt;&lt;/b&gt;&quot;.&lt;/li&gt;
&lt;li&gt;In below given code I am using true for IgnoreUserPrivacy. Default it should be false but i also wanted to make this work.&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;UserProfileManager(SPServiceContext.Current , &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;b style=&quot;color:Red&quot;&gt;Most Important&lt;/b&gt; : The user i am using to run this is an Admin in User Profile Service. So the code is working fine.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class=&quot;csharpcode&quot;&gt;SPSecurity.RunWithElevatedPrivileges(&lt;span class=&quot;kwrd&quot;&gt;delegate&lt;/span&gt;()
{
    &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (SPSite _site = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SPSite(SPContext.Current.Site.Url))
    {
        &lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (SPWeb _web = _site.OpenWeb())
        {
            &lt;span class=&quot;rem&quot;&gt;//Gets the profile manager object&lt;/span&gt;
            UserProfileManager _profileManager = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; UserProfileManager(SPServiceContext.Current , &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;);
                           
            &lt;span class=&quot;rem&quot;&gt;//UserName&lt;/span&gt;
            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; _userName = &lt;span class=&quot;str&quot;&gt;@&quot;MyMachine\User&quot;&lt;/span&gt;;

            &lt;span class=&quot;rem&quot;&gt;//Gets the profile of a User&lt;/span&gt;
            UserProfile _userProfile = _profileManager.GetUserProfile(_userName);
            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_userProfile != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
            {
                &lt;span class=&quot;rem&quot;&gt;//Change the Email value&lt;/span&gt;
                ((UserProfileValueCollection)_userProfile[&lt;span class=&quot;str&quot;&gt;&quot;WorkEmail&quot;&lt;/span&gt;]).Value = &lt;span class=&quot;str&quot;&gt;&quot;sample@someDomain.com&quot;&lt;/span&gt;;
                               
                &lt;span class=&quot;rem&quot;&gt;//Save the record&lt;/span&gt;
                _userProfile.Commit();
                               
            }
        }
    }
});&lt;/pre&gt;&lt;br /&gt;
This code works absolutely fine. For the developers who are getting issue like &quot;&lt;a href=&quot;http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-you-must-have-manage.html&quot;&gt;You must have manage user profiles administrator rights to use administrator mode.&lt;/a&gt;&quot; please click the error to visit the solution.</content><link rel='replies' type='application/atom+xml' href='http://maulikdhorajia.blogspot.com/feeds/2877796253881130687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-update-users-infomation.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/2877796253881130687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1010348719342749753/posts/default/2877796253881130687'/><link rel='alternate' type='text/html' href='http://maulikdhorajia.blogspot.com/2012/01/sharepoint-2010-update-users-infomation.html' title='SharePoint 2010 - Update user&#39;s infomation using UserProfileManager programmatically.'/><author><name>Maulik Dhorajia</name><uri>http://www.blogger.com/profile/12335234140583054583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>