<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hristo Yankov&#039;s Blog</title>
	<atom:link href="http://hyankov.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hyankov.wordpress.com</link>
	<description>My online brain dump</description>
	<lastBuildDate>Tue, 06 Nov 2012 12:45:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hyankov.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Hristo Yankov&#039;s Blog</title>
		<link>http://hyankov.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hyankov.wordpress.com/osd.xml" title="Hristo Yankov&#039;s Blog" />
	<atom:link rel='hub' href='http://hyankov.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to implement HTML5 Canvas undo function</title>
		<link>http://hyankov.wordpress.com/2010/12/26/how-to-implement-html5-canvas-undo-function/</link>
		<comments>http://hyankov.wordpress.com/2010/12/26/how-to-implement-html5-canvas-undo-function/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 14:54:04 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[undo]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/?p=382</guid>
		<description><![CDATA[HTML 5 is awesome. My most favorite feature is the canvas. It has many uses and of them is to allow the users of your website to draw free shapes. If that&#8217;s what your website utilizes the canvas element for, by no doubt you have already identified the need for an &#8216;undo&#8217; function. Perhaps you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=382&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>HTML 5 is awesome. My most favorite feature is the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html">canvas</a>. It has many uses and of them is to allow the users of your website to draw free shapes.</p>
<p>If that&#8217;s what your website utilizes the canvas element for, by no doubt you have already identified the need for an &#8216;undo&#8217; function. Perhaps you have already tried the .save() and .restore() functions, only to realize that they only save and restore the fill style of the drawing shapes.</p>
<p>This is exactly the problem I had, while creating my online <a href="http://ragecomic.appspot.com/">Rage Comic Editor</a>. Fortunately, I implemented a solution, which I would like to share with you.</p>
<p>The following tutorial assumes that you are familiar with the canvas element and its usage. It will only explain the technique I have discovered to save and restore a canvas drawing state. The implementation is (naturally) in JavaScript.</p>
<p>First, and most important, I have an <strong>online demo</strong> illustrating the tutorial, <a href="http://yankov.us/canvasundo/">here</a>. If you are inpatient or want to get straight to the code, feel free to navigate there and &#8216;view source&#8217;. It is well commented and should be self-explanatory.</p>
<p>In the demo I didn&#8217;t bother to implement a &#8216;free hand drawing&#8217; tool. Instead, I have two buttons only &#8211; one of them draw lines on the canvas and the other button undoes one step at a time.</p>
<p>Now to the point&#8230; The whole technique consists of three parts:</p>
<ol>
<li>You need an array, to store the &#8216;restore points&#8217; (much like Windows Restore Points). We will push states in it, when performing changes on the canvas, and will pop (and restore) states, out of it, when we press the &#8216;undo&#8217; button. Here is how I have declared it: <strong>var restorePoints = [];</strong></li>
<li>As mentioned, before performing any change on the canvas, we need to store its state. We do this, by calling the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-todataurl">toDataURL</a> of the canvas, which exports the current drawing in your canvas, to a (PNG) image, encoded as base64. Basically, we ask the canvas to give us a text representation of the image that is drawn. Now we only need to insert this text, as an element of our <strong>restorePoints</strong> array. We do this using the <strong>restorePoints.push(&#8230;) </strong>command. The implementation of this step is in the <strong>saveRestorePoint()</strong> function in the <a href="http://yankov.us/canvasundo/">example</a>. Again &#8211; you have to call this method, <strong>before</strong> performing a change on the canvas!</li>
<li>Now, how do we restore the canvas to its previous state, when the user clicks on an &#8216;undo&#8217; button? We call a javascript method in which we have to create a new Image object in the memory, set its &#8216;src&#8217; property to the last element in the <strong>restorePoints </strong>array (we do this using the array pop() method, which also removes the element from the array &#8211; exactly what we need!) and draw this image on the canvas (using the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-drawimage">drawImage()</a> function). So effectively what we do is: we take the last restoration point (image) and overlay it on top of the current state of the canvas. This will cause the effect of removing only the <span style="text-decoration:underline;">last change</span> on your canvas, because we have restored to a point, which is previous to that change. We also need to remove the restoration point from the array, because we are currently &#8216;in it&#8217; anyway.</li>
</ol>
<p>And that&#8217;s about it. To summarize: maintain a javascript array of the previous states of the canvas. Before you perform a change on the canvas, save the current state, by exporting the canvas to a base64 encoded image. Store that state in the array of states, then do your change. When you want to &#8216;undo&#8217;, .pop() the last state from the canvas and draw it on top of everything. This will overwrite the whole canvas, but will only remove your last change, because the restoration point is <strong>before </strong>it.</p>
<p>I think there is no better explanation than a code sample, so go ahead and view the source of <a href="http://yankov.us/canvasundo/">the demo</a>. You can download the complete solution from <a href="http://www.box.net/shared/rvkvt346jp">here</a>.</p>
<p>Cheers and Merry Christmas!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/382/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=382&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2010/12/26/how-to-implement-html5-canvas-undo-function/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>ChartPart for SharePoint</title>
		<link>http://hyankov.wordpress.com/2010/06/22/chartpart-for-sharepoint/</link>
		<comments>http://hyankov.wordpress.com/2010/06/22/chartpart-for-sharepoint/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 16:22:47 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[chart]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[web part]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/?p=366</guid>
		<description><![CDATA[If you would like to generate some charts in Microsoft SharePoint 2007, after a quick search you will find that there is no such out-of-the-box functionality. You shouldn&#8217;t worry, though, as there is a free web part available at Codeplex, which has everything you need for your list-based charting needs. It is called &#8220;ChartPart for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=366&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you would like to   generate some charts in Microsoft SharePoint 2007, after a quick search   you will find that there is no such out-of-the-box functionality. You   shouldn&#8217;t worry, though, as there is a free web part available at   Codeplex, which has everything you need for your list-based charting   needs. It is called &#8220;<strong>ChartPart for SharePoint</strong>&#8221; and is available <a href="http://chartpart.codeplex.com/">here</a>.</p>
<p><span style="font-size:large;"><strong>Prerequisites</strong></span></p>
<p>In order to get it working   on your server, you will need to have <a href="http://www.microsoft.com/downloads/details.aspx?familyid=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;displaylang=en">Microsoft   .NET 3.5 SP1</a> and <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;displaylang=en">Microsoft   Chart Controls for Microsoft .NET Framework 3.5</a> installed. The   &#8216;installation package&#8217; does not check for those prerequisites, so make   sure you do that manually before you install. Most probably you already   have .NET 3.5 SP1 installed, but chances are, the MS Chart Controls are   not installed.</p>
<p><span style="font-size:large;"><strong>Installation</strong></span></p>
<p>The   deployment package consists of two WSP files (SharePoint solution   deployment packages) &#8211; MSChartControls.wsp and ChartPart 2.0.wsp. First,   you have to install the MSChartControls package. Login on your   SharePoint server, start the Console (Start -&gt; Run -&gt; cmd) and   type:</p>
<p><strong>stsadm -o addsolution –filename MSChartControls.wsp<br />
stsadm -o execadmsvcjobs </strong></p>
<p><strong>STSADM NOTE</strong>: Of   course, you will have to choose between the convenience of not typing   the full path to the stsadm.exe file or not having to type the full path   to the WSP. So, you have to be in one of the two folders and type the   full path to the other file.</p>
<p>This will add the  solution  to the SharePoint Central Administration -&gt; Operations  -&gt;  Solution Management. You can either use the User Interface it  provides  to deploy the added solution, or you can continue executing  console  commands, like this:</p>
<p><strong>stsadm -o deploysolution -name   MSChartControls.wsp -immediate –allowgacdeployment<br />
stsadm -o execadmsvcjobs </strong></p>
<p>Then, you have to   activate the installed solution on Web Application level:</p>
<ol>
<li>Go   to Central Administration</li>
<li>Go to Application Management</li>
<li>Select Manage Web Application Features</li>
<li>Verify that you have selected the correct Web Application in the top   right corner</li>
<li>Click Activate on the Microsoft Chart Controls Feature</li>
</ol>
<p>Now, you have to do something similar for the other WSP (Chart   Part 2.0.wsp):</p>
<p><strong>stsadm -o addsolution -filename &#8220;ChartPart   2.0.wsp&#8221;<br />
stsadm -o execadmsvcjobs </strong></p>
<p>Deploy the solution,   either from Central Admin, or by using the console:</p>
<p><strong>stsadm -o   deploysolution -name &#8220;Chartpart 2.0.wsp&#8221; -immediate -allowCasPolicies   -url &lt;url&gt;<br />
stsadm -o execadmsvcjobs</strong></p>
<p>Where &lt;url&gt; is the   address of the web site you wish to deploy the webpart to. Now all you   have to do is activate the feature on the selected Site Collection.</p>
<ol>
<li>Go   to Site Settings for your top-level site</li>
<li>Go To Site Collection Features</li>
<li>Activate the ChartPart for SharePoint feature</li>
<li>Now you can add ChartParts on every site in your Site Collection.</li>
</ol>
<p><span style="font-size:large;"><strong>Usage</strong></span></p>
<p>I   created a new &#8216;Web Part Page&#8217; on my site, to use for experimenting  with  the web parts. I chose &#8216;Full Page, Vertical&#8217; layout template, as  it  is  one of the simplest and I preferred to have full width.</p>
<p>I   chose to &#8216;Edit Page&#8217; and clicked on &#8216;Add a Web Part&#8217; link in the  design  mode of the page. A pop-up showing all available web parts  appears and  from there, I chose to add on the page the &#8216;ChartPart&#8217; web  part.</p>
<p><a href="http://4.bp.blogspot.com/_1H2CoBAoOc8/TA-rVTcdwjI/AAAAAAAAKuw/_bPW3sZU_WU/s1600/web+part.PNG"><a href="http://hyankov.files.wordpress.com/2010/06/webpart1.png"><img class="alignnone size-medium wp-image-367" title="Web Part" src="http://hyankov.files.wordpress.com/2010/06/webpart1.png?w=300&#038;h=241" alt="" width="300" height="241" /></a><br />
</a></p>
<p>Once added on   the page, you have to configure it. While the page is still in design   mode, click on the little arrow down in the right upper corner of the   web part. It will open a side menu. Click on &#8216;Modify Shared Web Part&#8217;.   This will open the options of the web part.</p>
<p><a href="http://hyankov.files.wordpress.com/2010/06/config1.png"><img class="alignnone size-full wp-image-368" title="config[1]" src="http://hyankov.files.wordpress.com/2010/06/config1.png?w=630" alt=""   /></a></p>
<p>Here, you can   set the title of the web part (as it will appear on the page it is   added to), the web site to pull data from, the specific list and its   view. Then you have to select X and Y &#8220;Series&#8221; column. A bit of   explanation&#8230; Only Number fields can be choses as &#8220;X-Series&#8221;. &#8220;Item   Count&#8221; is always available to you. As &#8220;Y-Series&#8221; you have to specify a   column of the SharePoint list.</p>
<p>To illustrate all this, I   will configure my list to contain only two columns &#8211; &#8220;City&#8221; (single   line of text) and &#8220;Population&#8221; (number field). Here is what my list   looks like:</p>
<p><a href="http://hyankov.files.wordpress.com/2010/06/list1.png"><img class="alignnone size-full wp-image-369" title="List" src="http://hyankov.files.wordpress.com/2010/06/list1.png?w=630" alt=""   /></a></p>
<p>Now, I want   to configure the Chart web part to visualize this statistics. I will set   it up this way:</p>
<p><a href="http://hyankov.files.wordpress.com/2010/06/configured1.png"><img class="alignnone size-full wp-image-370" title="Configured" src="http://hyankov.files.wordpress.com/2010/06/configured1.png?w=630" alt=""   /></a></p>
<p>We click OK   button and the generated chart looks like:</p>
<p><a href="http://hyankov.files.wordpress.com/2010/06/generatedchart1.png"><img class="alignnone size-full wp-image-371" title="Generated Chart" src="http://hyankov.files.wordpress.com/2010/06/generatedchart1.png?w=630" alt=""   /></a></p>
<p><span style="font-size:large;"><strong>Customization</strong></span></p>
<p>You can customize the chart   in many ways. First. by selecting the &#8216;Chart Type&#8217; for the chart.   Choices are Column, Bar, Pie and so many others. Additionally, you can   select &#8216;Style&#8217; (Cylinder, Emboss, LightToDark, Wedge), which seems to   work only on specific &#8216;Chart Types&#8217;. For example, it clearly works on a   &#8216;Column&#8217; chart type. Here is the difference between &#8216;Cylinder&#8217; and   &#8216;Wedge&#8217;:</p>
<p><a href="http://hyankov.files.wordpress.com/2010/06/difference1.png"><img class="alignnone size-full wp-image-372" title="difference" src="http://hyankov.files.wordpress.com/2010/06/difference1.png?w=630" alt=""   /></a></p>
<p>There is many other fine   tunings you can do, like color palette, size and etc. Also what&#8217;s   really nice is that in the tooltip (when you hover a column in the   chart) you will see an exact value, of the column.</p>
<p><span style="font-size:large;"><strong>Conclusion</strong></span></p>
<p>ChartPart for SharePoint is a   great component, if you want to visualize some statistics based on   SharePoint list items. It is highly customizable, easy to install and   use.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/366/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=366&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2010/06/22/chartpart-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/webpart1.png?w=300" medium="image">
			<media:title type="html">Web Part</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/config1.png" medium="image">
			<media:title type="html">config[1]</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/list1.png" medium="image">
			<media:title type="html">List</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/configured1.png" medium="image">
			<media:title type="html">Configured</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/generatedchart1.png" medium="image">
			<media:title type="html">Generated Chart</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/06/difference1.png" medium="image">
			<media:title type="html">difference</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET MVC: Create Facebook-like search box</title>
		<link>http://hyankov.wordpress.com/2010/02/09/asp-net-mvc-create-facebook-like-search-box/</link>
		<comments>http://hyankov.wordpress.com/2010/02/09/asp-net-mvc-create-facebook-like-search-box/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:18:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[like]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2010/02/09/asp-net-mvc-create-facebook-like-search-box</guid>
		<description><![CDATA[In today&#8217;s article I will show you how to create your own Facebook-like (or LinkedIn-like) search box. If you haven&#8217;t seen what it looks like, here is an example: You will notice that it features: autocomplete, icon, matches what you type and when you click a result item, it takes you to the appropriate page. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=62&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em></em>In today&#8217;s article I will show you how to create your own <a href="http://facebook.com/">Facebook</a>-like (or LinkedIn-like) search box. If you haven&#8217;t seen what it looks like, here is an example:</p>
<div class="separator" style="clear:both;text-align:center;"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/searchexample.png"><img src="http://hyankov.files.wordpress.com/2010/02/searchexample.png?w=400&#038;h=160" alt="" width="400" height="160" border="0" /></a></div>
<p>You will notice that it features: autocomplete, icon, matches what you type and when you click a result item, it takes you to the appropriate page. That&#8217;s what our control in MVC will feature too. We will implement this in ASP.NET MVC2 and jQuery.</p>
<p><span class="fullpost"><br />
<span style="text-decoration:underline;"><strong>The Plan:</strong></span><br />
We will create an attribute and use it to decorate the action methods of our controllers. When we decorate an action, we will be adding metadata, such as the display name it should appear with in the search results and an optional icon. When the user types something in the search control, we will use jQuery to POST to a special controller, which will be enumerating all action methods in all controllers. While enumerating, it will be looking for a match between the search query and the metadata of each &#8216;indexed&#8217; action method.</span></p>
<p><span style="text-decoration:underline;"><strong>Implementation</strong></span></p>
<p><strong><span style="color:red;">Note: You can download the working demo project from </span><a style="color:red;" href="http://yankov.us/ActivitySearch.zip">here</a><span style="color:red;">. </span></strong><br />
<span class="fullpost"><strong><span style="color:red;">Visit the project page here: <a href="http://yankov.us/#Projects">http://yankov.us/#Projects</a> </span></strong></span></p>
<p><strong>The Attribute</strong><br />
Ok, let&#8217;s start with the attribute. In your Code folder (if you don&#8217;t have one &#8211; go ahead and create it) add a new class and name it &#8216;ActivitySearchAttribute&#8217;. It will have two string properties &#8211; Text and ImageUrl. Implement it like that:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/activitysearchattribute.png"><img src="http://hyankov.files.wordpress.com/2010/02/activitysearchattribute.png?w=640&#038;h=336" alt="" width="640" height="336" border="0" /></a></span></div>
<p><span class="fullpost"><br />
This is the attribute we will be using to decorate our action methods in the controllers. That way we will mark them as &#8216;searchable&#8217;.</span></p>
<p><strong>Action-Method Decorations</strong><br />
Let&#8217;s create a couple of dummy controllers, with a couple of actions in each of them and decorate them with the newly created attribute. Like this:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"> <a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/decorations.png"><img src="http://hyankov.files.wordpress.com/2010/02/decorations.png?w=400&#038;h=276" alt="" width="400" height="276" border="0" /></a></span></div>
<div class="separator" style="clear:both;text-align:left;"><span class="fullpost"><br />
</span></div>
<p><span class="fullpost">As you can see, the icon property (&#8220;group.png&#8221; in the example) in the metadata is optional. Non-decorated action methods will not be returned as search results.</span></p>
<p><strong>The Search Controller</strong><br />
Now let&#8217;s implement the search controller. Basically, what it will be doing is: receive a query string (e.g. &#8220;the&#8221;, as in the first image of this post), get all controllers, enumerate the action method of each controller, match the &#8216;Text&#8217; property of the &#8216;ActivitySearch&#8217; attribute (which we use to decorate the action) and then return an array of the matches with the appropriate URL to each result. Just like Facebook. I won&#8217;t paste the code here, as it is big, but you will find it in the attached sample project. The file is in Controllers and is named &#8220;SearchController.cs&#8221;.</p>
<p><strong>Json Response</strong><br />
The search will be a dynamic thing. While the user types, we will be sending a request to a controller and we will be receiving a response. We need to create a class which we will serialize to JSON and use it as a response. In your Code folder, create another class and name it &#8216;ActivitySearchResultItem&#8217;. It will have three properties: Text, Url and Image. Implement it like that:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/activitysearchresultitem.png"><img src="http://hyankov.files.wordpress.com/2010/02/activitysearchresultitem.png?w=640&#038;h=260" alt="" width="640" height="260" border="0" /></a></span></div>
<p><span class="fullpost">The Search controller will be returning an array of those, to the jQuery UI, as a JSON response. </span></p>
<p><strong>The JavaScript / jQuery</strong><br />
Now, when we have the back-end, we just need to implement the front-end in jQuery and html. Note that our solution will be using a 3rd party library &#8211; <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">jquery.autocomplete.pack.js</a><br />
Additionally, we will put our javascript, in a file named &#8220;activitySearch.js&#8221;.</p>
<p>The auto-complete jQuery plugin will take care of attaching to the text-box and submitting/receiving data to/from the back-end controller. We just need to process and format the results. When the user clicks a result, he will be redirected to the URL property associated with the result item (see &#8216;Json Response&#8217; above). Like that:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/jquery.png"><img src="http://hyankov.files.wordpress.com/2010/02/jquery.png?w=400&#038;h=362" alt="" width="400" height="362" border="0" /></a></span></div>
<p><span class="fullpost">As you can see, the jQuery code expects that if there is an Image associated with the search result it should be in the /Content/images folder.</span></p>
<p><strong>HTML</strong><br />
Here is how to setup your page which will contain the search-box control.</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/html.png"><img src="http://hyankov.files.wordpress.com/2010/02/html.png?w=640&#038;h=244" alt="" width="640" height="244" border="0" /></a></span></div>
<p><span class="fullpost"><br />
<span style="text-decoration:underline;"><strong>Conclusion</strong></span><br />
Now, when you have everything in place, start the project and just type in the search box some phrase which you know will hit a result. You should see something like:<br />
</span></p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/endresult.png"><img src="http://hyankov.files.wordpress.com/2010/02/endresult.png?w=320&#038;h=242" alt="" width="320" height="242" border="0" /></a></span></div>
<p><span class="fullpost"><br />
The search results are clickable and when clicked, it will take you to the appropriate action. You can optimize the whole solution with various caching settings and techniques.</span></p>
<p>You can download the whole demo project here &#8211; <a href="https://www.box.com/s/aeec42c7d2db49c699a3" rel="nofollow">https://www.box.com/s/aeec42c7d2db49c699a3</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=62&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2010/02/09/asp-net-mvc-create-facebook-like-search-box/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/02/searchexample.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/activitysearchattribute.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/decorations.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/activitysearchresultitem.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/jquery.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/html.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/endresult.png?w=300" medium="image" />
	</item>
		<item>
		<title>ASP.NET MVC2 &#8211; Creating a Display Template</title>
		<link>http://hyankov.wordpress.com/2010/02/05/asp-net-mvc2-creating-a-display-template/</link>
		<comments>http://hyankov.wordpress.com/2010/02/05/asp-net-mvc2-creating-a-display-template/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 15:08:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[displayfor]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2010/02/05/asp-net-mvc2-creating-a-display-template</guid>
		<description><![CDATA[ASP.NET MVC philosophy is &#8220;Skinny Controller, Fat Model, Stupid View&#8220;. The focus of today&#8217;s post is &#8220;stupid view&#8221;. What does this mean? Well, it means that you should avoid writing any logic in your views. A view should be as simple as wrapping the model&#8217;s properties in html tags. If you are cornered, and must [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=61&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em></em>ASP.NET MVC philosophy is &#8220;Skinny Controller, Fat Model, <strong>Stupid View</strong>&#8220;. The focus of today&#8217;s post is &#8220;stupid view&#8221;. What does this mean? Well, it means that you should avoid writing any logic in your views. A view should be as simple as wrapping the model&#8217;s properties in html tags.</p>
<p>If you are cornered, and must have some kind of a login in your view, it would be nice if it is neatly wrapped in a DisplayTemplate, so your code remains reusable, easy to read and maintain. What follows now is a tutorial on how to create one.</p>
<p><span class="fullpost"><br />
<strong>Problem: </strong>We have a Model which has a property &#8220;RemainingTime&#8221;, which is an integer and represents the estimated remaining seconds of some operation. We want to neatly format this time in the view, so that if it has a value of, let&#8217;s say, &#8220;5&#8243;, to be displayed as &#8220;5 seconds&#8221;. If it has value of &#8220;70&#8243;, to be displayed as &#8220;1 min, 10 seconds&#8221;, etc&#8230;</span></p>
<p><strong>Solution: </strong>Create a reusable DisplayTemplate and use it to visualize the property.</p>
<p>We start by creating a new ASP.NET MVC2 &#8220;empty&#8221; project template. We don&#8217;t need the default authentication and home controllers, so that would do just fine.</p>
<p>As a first step, let&#8217;s create our Model. We&#8217;ll call it &#8220;RemainingTimeModel&#8221; and will have the integer property &#8220;EstimatedSeconds&#8221;. We will name the DisplayTemplate &#8220;SecondsFormatting&#8221;. So we go ahead and decorate the &#8220;EstimatedSeconds&#8221; property with the <strong>UIHint</strong> attribute, passing &#8220;SecondsFormatting&#8221; (which is the name of the DisplayTemplate we want to use) in its constructor. This attribute tells ASP.NET MVC which DisplayTemplate to use by default, for this property. Your code should look like this:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/model.png"><img src="http://hyankov.files.wordpress.com/2010/02/model.png?w=640&#038;h=374" border="0" alt="" width="640" height="374" /></a></span></div>
<p><span class="fullpost"> </span></p>
<p>Second step is to create the actual DisplayTemplate. It needs to reside in the &#8220;Views/Shared/DisplayTemplates&#8221; folder, and be named &#8220;SecondsFormatting.ascx&#8221;. So, create a &#8220;DisplayTemplates&#8221; folder in your Shared views, then right click it and Add -&gt; View. Check the &#8216;create partial view&#8217; checkbox and give it the name we mentioned above. By default, this will create non-strongly typed ViewUserControl. We will extend this, to an integer. Open the &#8220;SecondsFormatting.ascx&#8221; file and change the <span style="color:red;">Inherits=&#8221;System.Web.Mvc.ViewUserControl&#8221;</span> to <span style="color:red;">Inherits=&#8221;System.Web.Mvc.ViewUserControl<strong> </strong>&#8220;</span>. Now, when you refer to the Model object in this control, you are working with an integer. The Model that will be passed to this DisplayTemplate is the &#8220;EstimatedSeconds&#8221; property of the &#8220;RemainingTimeModel&#8221; model.</p>
<p>Now we just need to implement some logic in the control. Let&#8217;s do this:</p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/displaytemplate.png"><img src="http://hyankov.files.wordpress.com/2010/02/displaytemplate.png?w=640&#038;h=130" border="0" alt="" width="640" height="130" /></a></span></div>
<p><span class="fullpost"> </span></p>
<p>Ok, we have the model, which has the seconds property, and we have a DisplayTemplate for it. Now we jsut need to use it. For this purpose, we will create one simple controller, which creates a new instance of the model and initializes it, then passes the model to a view. In the view, we will have: <span style="color:red;">Html.DisplayFor(model =&gt; model.EstimatedSeconds)</span>. Like that:</p>
<p><strong><span style="font-size:x-small;">(Controller)</span></strong></p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/controller.png"><img src="http://hyankov.files.wordpress.com/2010/02/controller.png?w=640&#038;h=432" border="0" alt="" width="640" height="432" /></a></span></div>
<p><span class="fullpost"> </span></p>
<p><span style="font-size:x-small;"><strong>(View)</strong></span></p>
<div class="separator" style="clear:both;text-align:center;"><span class="fullpost"><a style="margin-left:1em;margin-right:1em;" href="http://hyankov.files.wordpress.com/2010/02/view.png"><img src="http://hyankov.files.wordpress.com/2010/02/view.png?w=640&#038;h=164" border="0" alt="" width="640" height="164" /></a></span></div>
<p><span class="fullpost"> </span></p>
<p>See how clean your View remains? No logic in there, just a DisplayFor html helper call.</p>
<p>We can now go ahead and try it out, with a couple of different values. It formats it accordingly. Please note that there are much easier ways to format the time and it was used here just as an example of what we should do if our view requires to have a logic. If we try with 3732 seconds, it should display <strong>&#8220;1  hours, 2 minutes, 12 seconds&#8221;.</strong></p>
<p>Now you know how to encapsulate your logic in DisplayTemplates and keep your main Views clean and neat.<strong> </strong><br />
<strong><br />
</strong><br />
You can download the demo project from<strong> <a href="http://www.box.net/shared/lp0746rmy5">here</a>.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=61&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2010/02/05/asp-net-mvc2-creating-a-display-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2010/02/model.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/displaytemplate.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/controller.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2010/02/view.png?w=300" medium="image" />
	</item>
		<item>
		<title>SharePoint Console Application Requirements</title>
		<link>http://hyankov.wordpress.com/2009/11/26/sharepoint-console-application-requirements/</link>
		<comments>http://hyankov.wordpress.com/2009/11/26/sharepoint-console-application-requirements/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 15:35:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[cannot open database]]></category>
		<category><![CDATA[console app]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[filenotfound]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/11/26/sharepoint-console-application-requirements</guid>
		<description><![CDATA[So you have written a Console application which is working with the SharePoint Object Model (API), but you get an error. Something similar to: Cannot open database &#8220;WSS_Content_{GUID}&#8221; requested by the login. The login failed. Login failed for user &#8216;DOMAIN\User&#8216;. Or (* see additional notes below!): FileNotFoundException: The web application at http://some.site could not be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=56&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>So you have written a Console application which is working with the SharePoint Object Model (API), but you get an error. Something similar to:</p>
<div style="color:#cc0000;">Cannot open database &#8220;WSS_Content_<strong><em>{GUID}</em></strong>&#8221; requested by the login. The login failed.<br />
Login failed for user &#8216;<strong>DOMAIN\User</strong>&#8216;.</div>
<p>Or (<strong>* see additional notes below!</strong>):<br />
<span style="color:red;">FileNotFoundException: The web application at <a href="http://some.site" rel="nofollow">http://some.site</a> could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.</span></p>
<p><span class="fullpost"><br />
That&#8217;s because there are a couple of security requirements you need to meet. Basically, the user who is running the console application needs to:</p>
<ul>
<li>Be an Administrator on the computer he is running the app from (certainly, that would be the SharePoint server). Just add the user to the (Local) Administrators group on the machine.</li>
<li>Have sufficient rights within the SharePoint site. If you are doing some administrative tasks, you would want this user to be given &#8220;Full Control&#8221; (group).</li>
<li>Needs to have read/write permissions on the content database in the SQL server (or just make it db.owner). The database name is usually WSS_Content_{GUID}.</li>
</ul>
<p>After you have given those rights to the console application executing user, it should run fine. And by the way, if you think you can avoid giving those permissions, by running the API calls within <strong>SPSecurity.</strong><strong>RunWithElevatedPrivileges</strong>, you are wrong. The call itself, to SPSecurity.RunWithElevatedPrivileges would require them.</p>
<p><strong>* Additional note about FileNotFound:</strong><br />
Although this is not covered by this article, there might be other reasons for this error. For example: Site collection not existing on this location or you need to add Alternate Access Mapping.</p>
<p>Well, I hope this helps someone out there,<br />
Hristo Yankov</p>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=56&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/11/26/sharepoint-console-application-requirements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery in SharePoint</title>
		<link>http://hyankov.wordpress.com/2009/11/18/jquery-in-sharepoint/</link>
		<comments>http://hyankov.wordpress.com/2009/11/18/jquery-in-sharepoint/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 08:38:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/11/18/jquery-in-sharepoint</guid>
		<description><![CDATA[There are rumors jQuery might be included as part of SharePoint 2010. In an anticipation for that, today&#8217;s article aims to show what the integration between SharePoint 2007 and jQuery looks like, how to use it and what are the benefits. So what is jQuery? jQuery is a lightweight JavaScript library that emphasizes interaction between [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=55&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://upload.wikimedia.org/wikipedia/en/2/2f/Jquerylogo.png"><img src="http://upload.wikimedia.org/wikipedia/en/2/2f/Jquerylogo.png" border="0" alt="" /></a> <span style="font-weight:bold;"> </span><a href="http://www.methodfactory.com/solutions/sharepoint_2007/PublishingImages/SharePoint_Logo.jpg"><img src="http://www.methodfactory.com/solutions/sharepoint_2007/PublishingImages/SharePoint_Logo.jpg" border="0" alt="" /></a></p>
<p>There are <a href="http://www.endusersharepoint.com/2009/11/09/so-whats-up-with-jquery-in-sharepoint-2010/">rumors</a> <a href="http://jquery.com/">jQuery</a> <span style="font-weight:bold;">might</span> be included as part of SharePoint 2010. In an anticipation for that, today&#8217;s article aims to show what the integration between SharePoint 2007 and jQuery looks like, how to use it and what are the benefits.</p>
<p><span style="font-weight:bold;">So what is <a href="http://jquery.com/">jQuery</a></span><span style="font-weight:bold;">?</span><br />
<a href="http://en.wikipedia.org/wiki/JQuery">jQuery</a> is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. It was released in January 2006 at BarCamp NYC by John Resig. jQuery is free, open source software Dual-licensed under the MIT License and the GNU General Public License. Microsoft and Nokia have announced plans to bundle jQuery on their platforms, Microsoft adopting it initially within Visual Studio for use within <a href="http://blog.jquery.com/2008/09/28/jquery-microsoft-nokia/">Microsoft&#8217;s ASP.NET AJAX framework and ASP.NET MVC Framework whilst Nokia will integrate it into their Web Run-Time platform</a>.</p>
<p>Simply put, it is a high performance rapid development, AJAX-enabled library on top of JavaScript.</p>
<p><span class="fullpost"><br />
<span style="font-weight:bold;">API</span><br />
There are a lot of articles and tutorials out there, on how to use jQuery in general. Here is the most essential documentation you will need &#8211; the <a href="http://api.jquery.com/browser/">jQuery API</a>.</span></p>
<p><span style="font-weight:bold;">SharePoint integration</span><br />
Integration between jQuery and SharePoint boils down to finding a smart way to get a jQuery reference in your pages.</p>
<p>Basically you can do this &#8216;manually&#8217;, which is well described <a href="http://weblogs.asp.net/jan/archive/2008/11/20/sharepoint-2007-and-jquery-1.aspx">here</a> or you can use an automated integration solution (see below).</p>
<p>The manual approach essentially consists of two steps:<br />
1) Deploying the libraries (js) to a location which can be accessed by the pages &#8211; that would be the LAYOUTS folder in the 12 hive<br />
2) Loading the libraries on the pages &#8211; by modifying the master page, load the library specifically in the page you want to use it or other&#8230; It is all well described in the posted article.</p>
<p>The automated solution is a better one. You can get <a href="http://jqueryloader.codeplex.com/">&#8220;SmartTools jQueryLoader for SharePoint&#8221;</a> which does the integration for you. There is a <a href="http://weblogs.asp.net/jan/archive/2009/10/14/assembly-free-jquery-in-sharepoint-sites-using-the-smarttools-jqueryloader.aspx">good article</a> which walks you through the installation process, so we are not going to that here. Make sure you watch the video, though.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='630' height='385' src='http://www.youtube.com/embed/8DQrNpnSeXs?version=3&#038;rel=0&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span><a class="qtfbsyjuehmiadjqltky" href="http://www.youtube.com/v/8DQrNpnSeXs&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1"></a><a class="qtfbsyjuehmiadjqltky" href="http://www.youtube.com/v/8DQrNpnSeXs&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1"></a><a class="qtfbsyjuehmiadjqltky" href="http://www.youtube.com/v/8DQrNpnSeXs&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1"></a><br />
<span style="font-weight:bold;"><br />
Just try it out</span><br />
If you just want to quickly try the magic of jQuery in SharePoint out, without bothering with the full integration you can do what is described <a href="http://weblogs.asp.net/jan/archive/2009/05/06/querying-sharepoint-list-items-using-jquery.aspx">here</a>. The example in this article uses jQuery library which is hosted on Google Code (rather than in your 12 hive) and it dynamically queries the SharePoint web service to retrieve your current tasks, then visualizes them on the page. No need to develop a web part, it is just as simple as that!</p>
<p>You should also check <a href="http://cglessner.blogspot.com/2009/09/jquery-test-panel-for-sharepoint.html">this</a> out, although for some reason I couldn&#8217;t get it to work. Basically this is supposed to let you test any jQuery code, from a small &#8216;editor&#8217; on your home page.</p>
<p><span style="font-weight:bold;">Benefits</span><br />
So what are the benefits of using jQuery in SharePoint?</p>
<p><span style="font-style:italic;color:#3333ff;">AJAX</span><br />
Well, obviously it adds AJAX functionality to your SharePoint web application. You can now retrieve and visualize data asynchronously, without putting any load on the SharePoint server. It also allows you to create more appealing and faster UI.</p>
<p><span style="font-style:italic;color:#3333ff;">Page elements</span> <span style="font-style:italic;color:#3333ff;">control</span> <span style="font-style:italic;color:#3333ff;">and flexibility</span><br />
Additionally, SharePoint allows you to change content structure for subsites, lists, libraries, views, columns, content types and the Web parts, but sometimes that&#8217;s not enough. Sometimes developers/designers or users need to make changes to the functionality and appearance of a SharePoint site in a way that is not allowed by the IT department. Since SharePoint Designer is usually restricted, we need an <span style="font-style:italic;">alternative</span> way. That would be jQuery. Just to give you a concrete example of such situation, <a href="http://sharethelearning.blogspot.com/2008/11/jquery-in-sharepoint-example-rounded.html">here</a> is a guy who had to make the corners of the quick launch menu rounded.</p>
<p><span style="font-style:italic;color:#3333ff;">jQuery saves development time</span><br />
jQuery simplifies the way you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. To summarize it one sentence only: <span style="color:#ff0000;">couple of lines in jQuery allow you to do better what you could do with over 20 lines of JavaScript</span>.</p>
<p><span style="font-style:italic;color:#3333ff;">Many other&#8230;</span></p>
<ul>
<li>You don&#8217;t have to check for null objects</li>
<li>CSS3 compliant and has a great CSS selector integration</li>
<li>Huge community which supports it. Many tutorials out there&#8230;</li>
<li>Simple and fast development</li>
<li>Lightweight!</li>
<li>etc&#8230;</li>
</ul>
<p><span style="font-weight:bold;">Performance</span><br />
<a href="http://docs.jquery.com/Release:jQuery_1.3#Performance"></a>jQuery 1.3 is <a href="http://docs.jquery.com/Release:jQuery_1.3#Performance">fast</a>. As in the &#8220;fastest JS framework out there&#8221;. <a href="http://www.artzstudio.com/2009/04/jquery-performance-rules/">Here</a> are some nice tips on how to write a fast jQuery code.</p>
<p><span style="font-weight:bold;">Debugging jQuery in SharePoint</span><br />
<a href="http://getfirebug.com/">FireBug</a> is the preferred way to debug jQuery (and JavaScript in general). <a href="http://www.seifi.org/javascript/firebug_tips_and_tricks.html">Here</a> is a nice article which goes into details.</p>
<p><span style="font-weight:bold;">Examples<br />
</span><a href="http://www.endusersharepoint.com/">http://www.endusersharepoint.com/</a><span style="font-weight:bold;"> &#8211; <span style="font-style:italic;">THE</span> </span>&#8220;jQuery &amp; SharePoint&#8221; website.<span style="font-weight:bold;"><br />
</span><a href="http://pathtosharepoint.wordpress.com/2009/03/02/live-demo-jquery-sparklines/">jQuery sparklines</a><span style="font-weight:bold;"><br />
</span><a href="http://blog.mastykarz.nl/showing-random-images-sharepoint-2007-jquery/">Showing random images in SharePoint 2007 using jQuery</a><br />
<a href="http://www.sharepointkings.com/2008/12/highlight-sharepoint-list-rows.html">Highlight SharePoint List rows conditionally</a><br />
<a href="http://blog.mastykarz.nl/paging-large-content-sharepoint-jquery/">Paging large content in SharePoint using jQuery</a><br />
<a href="http://blog.chapmanconsulting.ca/2009/01/22/Add+Links+To+SharePoint+Wiki+Toolbar+Using+JQuery.aspx">Many other&#8230;</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=55&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/11/18/jquery-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/2/2f/Jquerylogo.png" medium="image" />

		<media:content url="http://www.methodfactory.com/solutions/sharepoint_2007/PublishingImages/SharePoint_Logo.jpg" medium="image" />
	</item>
		<item>
		<title>SharePoint Web Services Wrapper</title>
		<link>http://hyankov.wordpress.com/2009/07/28/sharepoint-web-services-wrapper/</link>
		<comments>http://hyankov.wordpress.com/2009/07/28/sharepoint-web-services-wrapper/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 20:43:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[managed]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[oriented]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[wrapper]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/28/sharepoint-web-services-wrapper</guid>
		<description><![CDATA[Recently I noticed that a common reason for developers to seek help on the MSDN forum is related to difficulties understanding and/or utilizing the SharePoint Web Services. You can&#8217;t blame the developers. It&#8217;s much more convenient to work with an Object Oriented API, rather than exchanging XML messages with a Web Service. For example, take [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=50&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Recently I noticed that a common reason for developers to seek help on the MSDN forum is related to difficulties understanding and/or utilizing the SharePoint Web Services. You can&#8217;t blame the developers. It&#8217;s much more convenient to work with an Object Oriented API, rather than exchanging XML messages with a Web Service. For example, take a look at the <a href="http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx">Lists.asmx -&gt; GetListItems</a>. Of course it&#8217;s no rocket science, but it will sure save time if you could avoid dealing with the XML directly.</p>
<p><span class="fullpost"><br />
I spent some time researching if there is some kind of a library out there which provides &#8216;managed&#8217; access to those Web Services. I.e. &#8211; work with .NET objects, rather than construct and parse XML elements. The closest thing I have found is <a href="http://blogs.msdn.com/asanto/archive/2004/12/30/344585.aspx">this</a> and it&#8217;s totally outdated and incomplete. At least it&#8217;s some reassurance to me that I am not missing the big picture and indeed, there might be people who would appreciate such framework.</span></p>
<p>So, I decided to start a project which will try to implement such .NET Object Oriented API around the SharePoint Web Services. Of course, for those corner weird cases (as well for the advanced developers), the underlying XML will still be accessible. <a href="http://www.csharphelp.com/archives4/archive602.html">Here</a> is a good description of all the SharePoint services. My goal is to cover them all, eventually. I will start with the most commonly used ones.</p>
<p>It is hosted on CodePlex &#8211; <a href="http://spwebserviceswrapper.codeplex.com/">http://spwebserviceswrapper.codeplex.com/</a><br />
The project is not published yet, as there is no single line of code written yet. I will be doing this in my spare time. Once I shape it to my liking, it will become open source and everyone is welcome to contribute.</p>
<p>Got comments? Suggestions/Objections? There is a similar library already implemented? Please do let me know.</p>
<p>Hristo</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=50&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/28/sharepoint-web-services-wrapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint bug udating title of uploaded xml</title>
		<link>http://hyankov.wordpress.com/2009/07/23/sharepoint-bug-udating-title-of-uploaded-xml/</link>
		<comments>http://hyankov.wordpress.com/2009/07/23/sharepoint-bug-udating-title-of-uploaded-xml/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 16:00:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[title]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/23/sharepoint-bug-udating-title-of-uploaded-xml</guid>
		<description><![CDATA[Another interesting case&#8230; Programmatically upload an xml file (extension should be .xml) to SharePoint document library. As soon as you upload it, try to change the Title field of the item. So here is the code: // We upload the file to SharePointSPFile file = Web.Files.Add(itemUrl, buff, true);Web.Update(); string newTitle = "Sample Title";SPListItem destItem = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=49&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Another interesting case&#8230;</p>
<p>Programmatically upload an xml file (extension should be .xml) to SharePoint document library. As soon as you upload it, try to change the Title field of the item.</p>
<p><span class="fullpost"><br />
So here is the code:</p>
<pre><span style="color:#33cc00;">// We upload the file to SharePoint</span>SPFile file = Web.Files.Add(itemUrl, buff, true);Web.Update();

string newTitle = "Sample Title";SPListItem destItem = file.Item;destItem.File.CheckOut();<span style="color:#33cc00;">// Try to change the title</span><span style="font-weight:bold;">destItem["Title"] = newTitle;</span>destItem.UpdateOverwriteVersion();destItem.File.CheckIn(string.Empty,SPCheckinType.MinorCheckIn);</pre>
<p>For any <span style="font-weight:bold;">non-xml extension files</span> it works, but for xml files the Title doesn&#8217;t change &#8211; it remains the same as the original name of the uploaded file. If you try doing this with another field of the item, it would work.</p>
<p>I came up with the following workaround:</p>
<pre>SPFile file = Web.Files.Add(itemUrl, buff, true);Web.Update();

string newTitle = "Sample Title";SPListItem destItem = file.Item;destItem.File.CheckOut();destItem["Title"] = newTitle;destItem.UpdateOverwriteVersion();

<span style="font-weight:bold;">// Work-around start</span><span style="font-weight:bold;">destItem["Title"] = newTitle;</span><span style="font-weight:bold;">destItem.Update();</span><span style="font-weight:bold;">// Workaround end</span>

destItem.File.CheckIn(string.Empty, SPCheckinType.MinorCheckIn);</pre>
<p>Anyone has clue what&#8217;s going on? Original MSDN forum thread is <a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/23dc1391-8407-46ae-9e88-d2c62a8c27cb">here</a>.</p>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=49&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/23/sharepoint-bug-udating-title-of-uploaded-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>Extending SharePoint Web Part</title>
		<link>http://hyankov.wordpress.com/2009/07/22/extending-sharepoint-web-part/</link>
		<comments>http://hyankov.wordpress.com/2009/07/22/extending-sharepoint-web-part/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 19:20:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[override]]></category>
		<category><![CDATA[rss view]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web part]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/22/extending-sharepoint-web-part</guid>
		<description><![CDATA[Hello! SharePoint provides a lot of different out-of-the-box Web Parts. But sometimes we wish a particular web part behaved in a little different way, or have some small extra functionality. Or we may want to implement a heavily modified Web Part, based on already existing one. Today, I will show you how to extend the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=48&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Hello!</p>
<p>SharePoint provides a lot of different out-of-the-box Web Parts. But sometimes we wish a particular web part behaved in a little different way, or have some small extra functionality. Or we may want to implement a heavily modified Web Part, based on already existing one.</p>
<p>Today, I will show you how to extend the functionality of an already existing web part.</p>
<p><span class="fullpost"><br />
We will take for example the <span style="font-weight:bold;">SharePoint RSS Viewer</span>. It loads an RSS feed and visualizes it in a web part on a SharePoint site. One of its visible properties in the UI is the Feed URL. It&#8217;s a static string and doesn&#8217;t allow any kind of dynamic parameters. Example:</p>
<ul>
<li>You can write: <a href="http://servername/service?Zip=92692" rel="nofollow">http://servername/service?Zip=92692</a></li>
<li>But you can&#8217;t: <a href="http://servername/service?Zip=" rel="nofollow">http://servername/service?Zip=</a><span style="font-weight:bold;">#zip_of_current_location#</span><span style="font-weight:bold;"> </span></li>
</ul>
<p>Or</p>
<ul>
<li>You can write: <a href="http://servername/service?IP=192.168.1.5" rel="nofollow">http://servername/service?IP=192.168.1.5</a></li>
<li>But you can&#8217;t: <a href="http://servername/service?IP=" rel="nofollow">http://servername/service?IP=</a><span style="font-weight:bold;">#current_ip#</span></li>
</ul>
<p>Those placeholders in my example are fictional, but you should get the idea of a dynamic value passed as a parameter to the service.</p>
<p>Our goal is to override the default behavior of the Feed URL field. We want to get to a point where we actually control how the Feed URL is being interpreted. We may want to replace placeholders with actual values, or do any other kind of adjustment of the URL, based on <span style="font-weight:bold;">current and dynamic</span> conditions.  So here is the plan: we create a new web part, inherit the RSS Viewer web part and extend the Feed URL property.</p>
<p>Let&#8217;s start. Here is how the RSS View part settings look like in edit mode:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/rssvieworiginal.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/rssvieworiginal.jpg?w=161" border="0" alt="" /></a></p>
<p>See the RSS Feed URL field? That&#8217;s what we are interested in.</p>
<p>Ok, start Visual Studio 2008 with the <span style="font-weight:bold;"><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=FB9D4B85-DA2A-432E-91FB-D505199C49F6&amp;displaylang=en">VSeWSS</a> plugin installed</span>. From the menu, start a new SharePoint -&gt; Web Part project.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/webpartproject.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/webpartproject.jpg?w=300" border="0" alt="" /></a></p>
<p>Give it a full trust<br />
<a href="http://hyankov.files.wordpress.com/2009/07/gactrust.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/gactrust.jpg?w=300" border="0" alt="" /></a></p>
<p>Change your namespace to something you prefer (for example, I will change it to <span style="font-weight:bold;">HristoYankov</span>). Rename the folder &#8216;WebPart1&#8242; to &#8216;RSSAggregatorWebPartDynamicParam&#8217;. It will rename all classes and files for you. In the Solution Explorer, expand Properties and open AssemblyInfo.cs. Add this to the bottom:<br />
<span style="font-weight:bold;">[assembly: AllowPartiallyTrustedCallers]</span></p>
<p>and this to the top:<br />
<span style="font-weight:bold;">using System.Security;</span></p>
<p>Your Solution Explorer should look similar to:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/se11.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/se11.jpg?w=300" border="0" alt="" /></a></p>
<p>Right click on your project, click on Properties, go to the Debug tab and set the SharePoint site URL you will be deploying to.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/debug.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/debug.jpg?w=300" border="0" alt="" /></a></p>
<p>Open the <span style="font-weight:bold;">RSSAggregatorWebPartDynamicParam.webpart</span> file and set Title and Description to whatever you like.</p>
<p>Now, after your project is setup, starts the interesting part. Let&#8217;s inherit the RSS View control! What you need to do is&#8230;</p>
<p>Add this file as a reference &#8211; <span style="font-weight:bold;">C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\microsoft.sharepoint.portal.dll</span>. This is where the RSS View class is defined.</p>
<p>Open your <span style="font-weight:bold;">RSSAggregatorWebPartDynamicParam.cs</span> file and change your class from this:<br />
<span style="font-weight:bold;">public class RSSAggregatorWebPartDynamicParam : System.Web.UI.WebControls.WebParts.WebPart</span></p>
<p>to that:<br />
<span style="font-weight:bold;">public class RSSAggregatorWebPartDynamicParam : RSSAggregatorWebPart</span></p>
<p>And add this statement:<br />
<span style="font-weight:bold;">using Microsoft.SharePoint.Portal.WebControls;</span></p>
<p>Basically, we no longer inherit the basic WebPart class. Instead, we now inherit the whole functionality of the RSS Viewer web part and all of its user interface!</p>
<p>You can also delete this function, as we are not going to do any changes there.<br />
<span style="font-weight:bold;">protected override void CreateChildControls()</span></p>
<p>So far so good. Now let&#8217;s override the Feed URL property! Add this to your class:</p>
<pre><span style="font-weight:bold;">[</span>DefaultValue(""),Resources("RSSWebpart_Property_FeedUrl_Text","RSSWebpart_ToolPart_Group","RSSWebpart_Property_FeedUrl_Description"),Personalizable(PersonalizationScope.Shared),WebBrowsable(true)<span style="font-weight:bold;">]</span>public <span style="font-weight:bold;">new </span>string FeedUrl{get{return base.FeedUrl;}set{base.FeedUrl = value;}}</pre>
<p>And add this statement:<br />
<span style="font-weight:bold;">using System.ComponentModel;</span></p>
<p>Three things to note here:<br />
1. The FeedUrl property is the one which handles the URL which points to the RSS feed.<br />
2. Note the attribute on top of the property. If you don&#8217;t add it, it won&#8217;t be visible in the UI<br />
3. Note the &#8216;new&#8217; keyword. This way we hide the underlying base FeedUrl property.</p>
<p>Ok, now we have control over the Feed URL. What we should do, is change the way FeedUrl is being returned. Change your <span style="font-weight:bold;">get</span> to look like:</p>
<pre>get{return OverrideURL(base.FeedUrl);}</pre>
<p>And create this function:</p>
<pre>private string OverrideURL(string url){// TODO: Process the URLreturn url;}</pre>
<p>So, in OverrideURL we can change any way we like the URL that is set in the User Interface and then return it modified. At this point, it is up to you how to utilize this capability.</p>
<p>For the purpose of the example, let&#8217;s just look for the string <span style="font-weight:bold;">#current_date#</span> in the URL and replace it with the current date.</p>
<pre>private string OverrideURL(string url){return url.Replace("#current_date#", DateTime.Now.ToShortDateString();}</pre>
<p>At the end, your code should look like:</p>
<pre>using System;using System.Runtime.InteropServices;using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint.WebPartPages;using Microsoft.SharePoint.Portal.WebControls;using System.ComponentModel;

namespace HristoYankov{[Guid("03badfa9-53e4-401a-bc60-28db88b202ac")]public class RSSAggregatorWebPartDynamicParam : RSSAggregatorWebPart{   public RSSAggregatorWebPartDynamicParam()   {   }

   [DefaultValue(""), Resources("RSSWebpart_Property_FeedUrl_Text", "RSSWebpart_ToolPart_Group", "RSSWebpart_Property_FeedUrl_Description"), Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]   public new string FeedUrl   {       get       {           return OverrideURL(base.FeedUrl);       }       set       {           base.FeedUrl = value;       }   }

   private string OverrideURL(string url)   {       return url.Replace("#current_date#", DateTime.Now.ToShortDateString());   }}}</pre>
<p>Now, right click your project and do &#8216;Deploy&#8217;. It should add a <span style="font-weight:bold;">RSSAggregatorWebPartDynamicParam </span>assembly to your GAC. When you go to your SharePoint site and do &#8216;Edit Page&#8217; -&gt; &#8216;Add Web Part&#8217;<br />
<a href="http://hyankov.files.wordpress.com/2009/07/addwebpart.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/addwebpart.jpg?w=300" border="0" alt="" /></a><br />
you should be able to see your newly created web part listed in the pop up. Add it to the page. Put it in Edit Settings mode and set the Feed Url to something like:<br />
<a href="http://servername/service/Param1=" rel="nofollow">http://servername/service/Param1=</a><span style="font-weight:bold;">#current_date#</span></p>
<p>It will be replaced by:<br />
<a href="http://servername/service/Param1=" rel="nofollow">http://servername/service/Param1=</a><span style="font-weight:bold;">06/06/2009</span> (for example)</p>
<p><span style="font-weight:bold;">NOTE:</span> I just noticed this &#8211; as soon as you set the URL which contains the &#8216;placeholder&#8217;, the web part which is still in edit mode starts showing it with a replaced value (the date). I believe that the underlying value is still <span style="color:#3333ff;"><a href="http://servername/service/Param1=" rel="nofollow">http://servername/service/Param1=</a></span><span style="font-weight:bold;"><span style="color:#3333ff;">#current_date#</span>. </span>So perhaps, in the method OverrideURL we should be taking into consideration if the web part is in edit mode. And if it is &#8211; just return the original parameter that was passed. Something like:</p>
<pre>private string OverrideURL(string url){if (this.NotInEditMode){// Not in edit mode, perform changesreturn url.Replace("#current_date#", DateTime.Now.ToShortDateString());}else{// We are in edit mode, return URL as isreturn url;}}</pre>
<p>I will be checking this later. As usual, you can get the full source code <a href="http://download735.mediafire.com/gnmmyic3q3wg/d5dze5t1jk2/RSSAggregatorWebPartDynamicParam.zip"><span style="font-weight:bold;">here</span></a>.</p>
<p>But basically that&#8217;s it. With minimum amount of code and effort, we have extended the functionality of an already existing web part, to something that serves our concrete needs.</p>
<p>Hope this was helpful!</p>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=48&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/22/extending-sharepoint-web-part/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/rssvieworiginal.jpg?w=161" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/webpartproject.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/gactrust.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/se11.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/debug.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/addwebpart.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>SharePoint Solution Hello World Tutorial</title>
		<link>http://hyankov.wordpress.com/2009/07/21/sharepoint-solution-hello-world-tutorial/</link>
		<comments>http://hyankov.wordpress.com/2009/07/21/sharepoint-solution-hello-world-tutorial/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:49:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/21/sharepoint-solution-hello-world-tutorial</guid>
		<description><![CDATA[Hi, In this post, I will explain to you how to create your first SharePoint 2007 ASP.NET application. We will cover what tools you would need and what are the steps to creating a SharePoint Hello World app! I will keep the article short and clear on the necessary steps to be followed. First, let&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=47&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Hi,</p>
<p>In this post, I will explain to you how to create your first SharePoint 2007 ASP.NET application. We will cover what tools you would need and what are the steps to creating a SharePoint Hello World app! I will keep the article short and clear on the necessary steps to be followed.</p>
<p><span class="fullpost"><br />
First, let&#8217;s start with the tools. You will need Visual Studio 2008 SP1 (preferably) this freely available plugin for it <a href="http://www.microsoft.com/downloads/details.aspx?familyid=7BF65B28-06E2-4E87-9BAD-086E32185E68&amp;displaylang=en">Visual Studio 2008 extensions for Windows SharePoint Services 3.0</a>. It is a toolset for developing custom SharePoint applications: Visual Studio project templates for Web Parts, site definitions, and list definitions; and a stand-alone utility program, the SharePoint Solution Generator.<a href="http://www.microsoft.com/downloads/details.aspx?familyid=7BF65B28-06E2-4E87-9BAD-086E32185E68&amp;displaylang=en"><br />
</a><br />
We assume that you have setup and you do have available a SharePoint site, on which we will be deploying our solution.</span></p>
<p>So, start your Visual Studio 2008. From the menu choose to start a new Project.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/newproject.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/newproject.jpg?w=300" border="0" alt="" /></a></p>
<p>Visual Studio will show this window. Select GAC and proceed.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/gac.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/gac.jpg?w=300" border="0" alt="" /></a></p>
<p>Your Solution Explorer would look like this, initially:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/se1.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/se1.jpg?w=300" border="0" alt="" /></a></p>
<p>We need to create a couple of folders. Recreate the folder structure described in the screenshot below:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/se2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/se2.jpg?w=300" border="0" alt="" /></a></p>
<p>Right click on HelloSharePointWorld and select add new item. Select text file, but name it &#8220;Hello.aspx&#8221;<br />
<a href="http://hyankov.files.wordpress.com/2009/07/addnewitem.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/addnewitem.jpg?w=300" border="0" alt="" /></a></p>
<p>Put the following content in your newly created ASPX page.</p>
<pre>&lt;%@ Page Language="c#"Inherits="Hello, SharePointHelloWorld, Version=1.0.0.0,Culture=neutral, PublicKeyToken=<span style="font-weight:bold;">3cf44204a7ad1f1e</span>"MasterPageFile="~/_layouts/application.master"%&gt;

&lt;asp:Content ID="Content1"ContentPlaceHolderID="PlaceHolderMain"runat="server"&gt;&lt;asp:Label ID="lblLabel1" runat="server" Text="Hello World!"&gt;&lt;/asp:Label&gt;&lt;/asp:Content&gt;</pre>
<p>Note the PublicKeyToken value. It will be changed later. Now, create a new class in the App_Code folder. Name it Hello.aspx.cs. Your directory structure should look like:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/se3.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/se3.jpg?w=300" border="0" alt="" /></a></p>
<p>The content of your Hello.aspx.cs should read:<br />
<span style="color:#3333ff;"></p>
<pre>using System;using Microsoft.SharePoint.WebControls;

public partial class Hello : LayoutsPageBase{ protected void Page_Load(object sender, EventArgs e) { }}</pre>
<p></span></p>
<p>Right click on your project, select Properties from the menu. Go to the Debug tab and set the hostname and port number of the SharePoint site where you want your project to be deployed.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/debug1.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/debug1.jpg?w=300" border="0" alt="" /></a></p>
<p>Then save.</p>
<p>Now, right click on your project in Solution Explorer and rebuild it. Then right click on it and Deploy.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/deploy.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/deploy.jpg?w=272" border="0" alt="" /></a></p>
<p>Now, open Windows Explorer and navigate to C:\WINDOWS\assembly. You should see an assembly called SharePointHelloWorld there. Right click it and select Properties.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/gac2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/gac2.jpg?w=262" border="0" alt="" /></a></p>
<p>Copy the Public Key Token (highlighted, note that it would be different for you) and click Cancel button. Now go back to your ASPX page in the project and replace the incorrect Public Key Token with the one you just copied.</p>
<p>Redeploy your application. Start Internet Explorer and navigate to <a href="http://%5Bserver" rel="nofollow">http://%5Bserver</a> name]:[port]/_layouts/HelloSharePointWorld/Hello.aspx</p>
<p>You should see something similar to:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/helloworld.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/helloworld.jpg?w=300" border="0" alt="" /></a></p>
<p>Congratulations, you have created your first SharePoint solution. If you start the Central Admin for SharePoint and go to Operations -&gt; Solution Management you should see a solution named <span style="font-weight:bold;">sharepointhelloworld.wsp</span>.</p>
<p>Let&#8217;s add one more modification. Open the Hello.aspx.cs file and change it to:<br />
<span style="color:#3333ff;"></p>
<pre>using System;using Microsoft.SharePoint.WebControls;using System.Web.UI.WebControls;

public partial class Hello : LayoutsPageBase{ protected Label lblLabel1;

 protected void Page_Load(object sender, EventArgs e) {     lblLabel1.Text = "Hello world! Time is: " +     DateTime.Now.ToString(); }}</pre>
<p></span></p>
<p>By that, we utilize the code behind to output data on the screen. Rebuild, redeploy and refresh the page.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/uinew.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/uinew.jpg?w=300" border="0" alt="" /></a></p>
<p>This is a good starting point for further learning by experimenting and example.</p>
<p>Of course, the full code for this project can be found <a href="http://download522.mediafire.com/l7niogtxj28g/jrdoymrywtm/SharePointHelloWorld.zip"><span style="font-weight:bold;">here</span></a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=47&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/21/sharepoint-solution-hello-world-tutorial/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/newproject.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/gac.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/se1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/se2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/addnewitem.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/se3.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/debug1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/deploy.jpg?w=272" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/gac2.jpg?w=262" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/helloworld.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/uinew.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>SharePoint 2010 overview</title>
		<link>http://hyankov.wordpress.com/2009/07/17/sharepoint-2010-overview/</link>
		<comments>http://hyankov.wordpress.com/2009/07/17/sharepoint-2010-overview/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 07:01:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[12]]></category>
		<category><![CDATA[2010]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/17/sharepoint-2010-overview</guid>
		<description><![CDATA[SharePoint is a collection of products and software tools by Microsoft that mainly provides collaboration functions, process management, searching and document management. Currently, the most popular version is SharePoint 2007. At this very moment Microsoft is working very hard on releasing the next version of the product &#8211; SharePoint 2010. This article will try to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=45&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>SharePoint is a collection of products and software tools by Microsoft that mainly provides collaboration functions, process management, searching and document management. Currently, the most popular version is SharePoint 2007. At this very moment Microsoft is working very hard on releasing the next version of the product &#8211; SharePoint 2010. This article will try to cover areas such as: what new features will be there, what changes from developer&#8217;s standpoint, what are the requirements, release date and others.</p>
<p><a href="http://blogs.msdn.com/sharepoint/archive/2009/04/14/microsoft-sharepoint-14-is-now-microsoft-sharepoint-2010.aspx"><span style="font-weight:bold;">Naming</span></a><br />
The product is no longer code-named &#8220;14&#8243;. The official name is <span style="font-weight:bold;">Microsoft SharePoint Server 2010</span>. The &#8216;Offfice&#8217; part of the name finally drops out. The Office brand will no longer include Server side components (such as SharePoint). It now clearly refers to the client applications, such as Word, Excel and etc.</p>
<p>On a separate note, Exchange 2010 will be shipped separately of Office (beta is out already).</p>
<p><span style="font-weight:bold;">New Features</span></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Microsoft_Groove">Groove</a> (document collaboration application, acquired by Microsoft) is now being renamed and transformed into <span style="color:#ff6600;">Microsoft Office SharePoint Workspace 2010</span>.</li>
<li><a href="http://blogs.msdn.com/sharepoint/archive/2009/05/07/announcing-sharepoint-server-2010-preliminary-system-requirements.aspx">SharePoint 2010 is not going to support Internet Explorer 6</a> (awesome). However, it will be supporting Firefox 3.x on Windows and perhaps even Firefox 3.x and Safari on non-Windows platforms.</li>
<li><a href="http://en.wikipedia.org/wiki/Master_Data_Management">Master Data Management (MDM)</a> will be <a href="http://blogs.zdnet.com/microsoft/?p=728">integrated with Office 14</a>.</li>
<li>SharePoint 2010 will be able to interact with other CMS systems through <a href="http://en.wikipedia.org/wiki/Content_Management_Interoperability_Services">CMIS</a>.</li>
<li>You will be able to map <a href="http://blog.sharepointproducts.com/archive/2009/05/12/microsoft-sharepoint-2010-news-from-teched-us-2009.aspx">SharePoint lists directly to database tables</a>, which will provide great performance and scalability, especially on large lists.</li>
<li>There will be Silverlight support and <a href="http://rapidapplicationdevelopment.blogspot.com/2009/05/secrets-of-sharepoint-2010-exposed-at.html"><span style="font-weight:bold;">maybe</span> AJAX</a>!</li>
<li>SharePoint Designer will support saving workflows to re-use for provisioning.</li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms563661.aspx">BDC </a><span style="font-weight:bold;">might </span>support Updating and Inserting data</li>
<li><a href="http://en.wikipedia.org/wiki/Faceted_search">Faceted Search</a></li>
<li><a href="http://www.microsoft.com/presspass/press/2009/feb09/02-10NewEnterpriseSearchPR.mspx">FAST Search for SharePoint</a>. A new version of FAST Search for SharePoint at a lower cost.</li>
<li><a href="http://www.informationweek.com/news/windows/operatingsystems/showArticle.jhtml?articleID=218500775&amp;subSection=Enterprise+Applications">&#8220;Web edit&#8221;</a> &#8211; <span style="font-style:italic;">&#8220;Microsoft has made it much easier for users to customize their own sites in SharePoint 2010. A new feature called Web edit allows site owners to edit their sites almost as if they were typical Office documents, making it easier for them to carry out common Web editing tasks like uploading and changing images or editing text.&#8221;</span></li>
<li><span id="articleBody">Other user-focused upgrades include the ability to use Office themes in SharePoint, for example by customizing a team site with the color palette of a SharePoint slide deck.</span></li>
<li><span id="articleBody">Read Visio documents in SharePoint</span></li>
<li><span id="articleBody">Improved administrative capabilities with a dashboard that uses the ribbon interface</span></li>
<li><span id="articleBody">Set of tools to monitor server farm health and data performance</span></li>
<li><span id="articleBody">Standardized UI across all Office products, browsers, mobile devices</span></li>
<li><span id="articleBody">Open API support</span></li>
</ul>
<p><span class="fullpost"><br />
The free (and light) <span style="font-weight:bold;">WSS</span> version of the product will still be available, although there is no much information regarding it. Microsoft <a href="http://blogs.msdn.com/sharepoint/archive/2009/04/14/microsoft-sharepoint-14-is-now-microsoft-sharepoint-2010.aspx">announced</a> that it will get a lot of new features and will be a &#8220;great release&#8221;.</span><br />
<span class="fullpost"><br />
<span style="font-weight:bold;">Developer tools</span><br />
So, having said all that, what changes from the developer perspective? Is our life going to become easier, or even harder?</span></p>
<p>Microsoft <a href="http://blogs.msdn.com/sharepoint/archive/2009/04/14/microsoft-sharepoint-14-is-now-microsoft-sharepoint-2010.aspx">announced</a> &#8220;deep support for industry standards&#8221; and the main development tool will be Visual Studio 2010. It will ship with comprehensive support for development in all SharePoint areas &#8211; Web parts, features, solutions, content types, etc.</p>
<p><span style="color:#ff6600;">Deploy and debug from VS</span><br />
You should be able to build, deploy and debug SharePoint applications directly from Visual Studio! If this is true, it will save us a lot of time!</p>
<p>Also, there will be a new <span style="color:#ff6600;">Server Explorer</span> window within VS, which we will use to explore SharePoint objects such as: Sites, Lists, Documents and other.</p>
<p><span style="color:#ff6600;">The Feature Designer</span> embedded in Visual Studio 2010 will provide a detailed look at all the components of a Feature.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/featuredesigner.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/featuredesigner.jpg?w=300" border="0" alt="" /></a></p>
<p><span style="color:#ff6600;">Package Explorer</span> will provide you a WYSIWYG view to your package. You should be able to re-arrange items within the package by drag&amp;drop!</p>
<p>There is extended support and <span style="color:#ff6600;">integration of the Team System</span>, if you are into this kind of a Source Control.</p>
<p><a href="http://blogs.msdn.com/sharepoint/archive/2009/05/07/announcing-sharepoint-server-2010-preliminary-system-requirements.aspx"><span style="font-weight:bold;">Requirements</span></a><br />
It is a good idea to start getting prepared for this release of SharePoint, as it has very specific system requirements.</p>
<ul>
<li>SharePoint 2010 will be 64-bit only</li>
<li>SharePoint Server 2010 will require 64-bit Windows Server 2008 or 64-bit Windows Server 2008 R2.</li>
<li>SharePoint Server 2010 will require 64-bit SQL Server 2008 or 64-bit SQL Server 2005.</li>
<li>As mentioned, IE 6 won&#8217;t be supported.</li>
</ul>
<p>Out of the article:<br />
<span style="color:#000099;">So, what can you do today to get into the best shape for SharePoint Server 2010?</span><br />
<span style="color:#000099;">1. Start by ensuring new hardware is 64-bit.  Deploying 64-bit is our current best practice recommendation for SharePoint 2007.</span><br />
<span style="color:#000099;">2. Deploy Service Pack 2 and take a good look at the SharePoint 2010 Upgrade Checker that’s shipped as part of the update.  The Upgrade Checker will scan your SharePoint Server 2007 deployment for many issues that could affect a future upgrade to SharePoint 2010.</span><br />
<span style="color:#000099;">3. Get to know Windows Server 2008 with SharePoint 2007, <a href="http://blogs.msdn.com/sharepoint/archive/2008/01/16/windows-server-2008-and-sharepoint-resources.aspx">this post</a> is a great starting point.</span><br />
<span style="color:#000099;">4. Consider your desktop browser strategy if you have large population of Internet Explorer 6 users.</span><br />
<span style="color:#000099;">5. Continue to follow the <a href="http://technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx">Best Practices</a> guidance for SharePoint Server 2007.</span><br />
<span style="color:#000099;">6. Keep an eye on this blog for updates and more details in the coming months.</span></p>
<p>And here are two interesting Q&amp;As:</p>
<p><strong>Q: Why are you only supporting the 64-bit versions of SQL Server 2005 or 2008 for SharePoint Server 2010?<br />
</strong>A: This decision was based on our current test data for SharePoint Server 2010 and real world experience from customers running SharePoint Server 2007 with 32-bit SQL Server.  SharePoint performance and scalability can benefit significantly from 64-bit SQL Server and the throughput increases are significant enough for us to make the difficult decision to only support SharePoint Server 2010 on 64-bit SQL Server 2005 or 2008.  It has been our strong recommendation for some time that SharePoint Server 2007 customers take advantage of 64-bit SQL Server due to the inherent performance and scale benefits it can provide.</p>
<p><strong>Q: Where can I find more information on the advantages of 64-bit hardware and guidance on how to migrate SharePoint from 32-bit to 64-bit.<br />
</strong>A: These two TechNet articles are a good starting point;</p>
<p><span style="font-weight:bold;">Release date</span><br />
According to Chris Capossela (senior vice president of Microsoft’s Information Worker Product Management Group) <a href="http://www.microsoft.com/presspass/features/2009/Apr09/04-15Office2010.mspx">SharePoint 2010 will enter a technical preview</a> in the third quarter of 2009 and will release to manufacturing in the first half of 2010.</p>
<p><span style="font-weight:bold;">Beta</span><br />
Microsoft <a href="http://www.infoworld.com/d/windows/microsoft-sharepoint-server-2010-beta-in-two-months-756">announced</a> that it is now testing the software in an invitation-only technical preview, with a public beta to follow later this year. It focuses on a number of its enterprise customers and target specific enterprise deployment scenarios.</p>
<p>So, there is still some waiting to be done. But waste no time, instead, start preparing your 64-bit environments!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=45&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/17/sharepoint-2010-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/featuredesigner.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>SharePoint regional settings double value bug</title>
		<link>http://hyankov.wordpress.com/2009/07/08/sharepoint-regional-settings-double-value-bug/</link>
		<comments>http://hyankov.wordpress.com/2009/07/08/sharepoint-regional-settings-double-value-bug/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:24:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[CultureInfo]]></category>
		<category><![CDATA[DefaultValue]]></category>
		<category><![CDATA[DefaultValueTyped]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[InvariantCulture]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[Regional Settings]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SPFieldNumber]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/08/sharepoint-regional-settings-double-value-bug</guid>
		<description><![CDATA[Here is an interesting one&#8230; I had to set the regional settings of my SharePoint site to Hungarian, so the DateTime fields get localized properly. This has been discussed previously here. However, I started experiencing problems with the double values. Explanation by example: (myField is of type SPFieldNumber) double myDouble = 123.45; myField.DefaultValue = myDouble.ToString(); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=44&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Here is an interesting one&#8230;</p>
<p>I had to set the regional settings of my SharePoint site to Hungarian, so the DateTime fields get localized properly. This has been discussed previously <a href="http://blog.myitechnology.com/2009/07/sharepoint-datetime-and-regional.html">here</a>.</p>
<p>However, I started experiencing problems with the double values. Explanation by example:<br />
(myField is of type SPFieldNumber)</p>
<p><span class="fullpost"><br />
<span style="color:#ff0000;">double myDouble = 123.45;</span><br />
<span style="color:#ff0000;">myField.DefaultValue = myDouble.ToString();</span></span></p>
<p>Basically, I am trying to assign the value of a type double variable as the default value of my SharePoint field (which I am about to render).</p>
<p>At this point, when I check (using Quick Watch in Visual Studio) the value of <span style="font-weight:bold;">myField.DefaultValue</span> it shows <span style="font-weight:bold;">123<span style="color:#ff0000;">,</span>45</span> (which is ok, for the localization I am using). However, <span style="font-weight:bold;">myField.DefaultValueTyped</span> shows <span style="font-weight:bold;">12345</span>. Looks like SharePoint is ignoring the fact that the site is localized and does not consider &#8216;,&#8217; to be in the role of a &#8216;.&#8217;</p>
<p><span style="font-weight:bold;">The solution I came up with is:</span><br />
<span style="color:#ff0000;">double myDouble = 123.45;</span><br />
<span style="color:#ff0000;">myField.DefaultValue = myDouble.ToString(<span style="font-weight:bold;">CultureInfo.InvariantCulture</span>);</span></p>
<p>Perhaps it is not the best, but at least the output now is:<br />
<span style="font-weight:bold;">myField.DefaultValue = &#8220;123,45&#8243;<br />
</span><span style="font-weight:bold;">myField.DefaultValueTyped = 123.45</span></p>
<p>Which is what is expected! Let me know if you know of a better way!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=44&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/08/sharepoint-regional-settings-double-value-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>stsadm command line error</title>
		<link>http://hyankov.wordpress.com/2009/07/07/stsadm-command-line-error/</link>
		<comments>http://hyankov.wordpress.com/2009/07/07/stsadm-command-line-error/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 08:34:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[command line error]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[installfeature]]></category>
		<category><![CDATA[stsadm]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/07/stsadm-command-line-error</guid>
		<description><![CDATA[There is a common problem with stsadm being executed from the command line. For example, you run: stsadm -o installfeature -name [featurename] And you get &#8220;Command line error.&#8221; in the console. It is because you have copy/pasted the command from your browser or somewhere else. There is a problem with the encoding. Solution: Type the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=43&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>There is a common problem with <span style="font-weight:bold;">stsadm </span>being executed from the command line. For example, you run:<br />
<span style="color:#ff0000;">stsadm -o installfeature -name [featurename]</span></p>
<p>And you get &#8220;<span style="color:#ff0000;">Command line error</span>.&#8221; in the console. It is because you have copy/pasted the command from your browser or somewhere else. There is a problem with the encoding.</p>
<p><span style="font-weight:bold;">Solution: Type the command in the console window, don&#8217;t paste it.</span></p>
<p>Hope this helps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=43&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/07/stsadm-command-line-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>Check if user belongs to K2 role</title>
		<link>http://hyankov.wordpress.com/2009/07/03/check-if-user-belongs-to-k2-role/</link>
		<comments>http://hyankov.wordpress.com/2009/07/03/check-if-user-belongs-to-k2-role/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 07:29:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[GetSCConnectionStringBuilder]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[HostClientAPI]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[role]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SourceCode]]></category>
		<category><![CDATA[UserRoleManager]]></category>
		<category><![CDATA[WindowsIdentity]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/03/check-if-user-belongs-to-k2-role</guid>
		<description><![CDATA[In your SharePoint (or other) / K2 solution, you may find yourself in a situation where you want to check if the current user belongs to a given K2 role. Perhaps, you want to allow only users who belong to particular K2 role to view a page, or you want to show a different page [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=41&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In your <span style="font-weight:bold;">SharePoint </span>(<span style="font-style:italic;">or other</span>) / <span style="font-weight:bold;">K2</span> solution, you may find yourself in a situation where you want to <span style="color:#ff0000;">check if the <span style="font-weight:bold;">current user</span> belongs to a given K2 role</span>. Perhaps, you want to allow only users who belong to particular K2 role to view a page, or you want to show a different page depending on the K2 role the user belongs to.</p>
<p><span class="fullpost"><br />
Surprisingly, K2 API does not provide a convenience method to do that. You have to implement it  yourself. Even further, K2 Roles may contain ActiveDirectory groups and you will have to check if the current user belongs to them! In this article, we will discuss how all this is being done.</span></p>
<p>In the project where you will be implementing this method, make sure you have references to those libraries (which should be in the GAC):</p>
<ul>
<li>SourceCode.HostClientAPI</li>
<li>SourceCode.Security.UserRoleManager.Management</li>
</ul>
<p>First, let&#8217;s think about the signature of our method. It needs to return a boolean and receive a K2 role name as parameter:<br />
<span style="color:#3333ff;">public static <span style="font-weight:bold;">bool </span>CurrentUserBelongsToK2Role(string <span style="font-weight:bold;">roleName</span>)</span></p>
<p>That should do it. Now let&#8217;s start implementing the method. We need to get the name of the current user.<br />
<span style="color:#3333ff;">string loginName = WindowsIdentity.GetCurrent().Name;</span></p>
<p>(By the way, <span style="font-weight:bold;">WindowsIdentity</span> is in <span style="font-weight:bold;">System.Security.Principal</span>)</p>
<p>What we have so far is:<br />
<span style="color:#3333ff;">public static bool CurrentUserBelongsToK2Role(string roleName)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> string loginName = WindowsIdentity.GetCurrent().Name;</span></p>
<p><span style="color:#3333ff;"> // TODO: Implement further</span></p>
<p><span style="color:#3333ff;"> return false;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Not much. We need to get an instance of K2&#8242;s <span style="font-weight:bold;">UserRoleManager</span> class. We will create a separate method which returns us an instance of this object:<br />
<span style="color:#3333ff;">public static UserRoleManager GetUserRoleManager()</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> UserRoleManager userRoleManager = new UserRoleManager();</span><br />
<span style="color:#3333ff;"> userRoleManager.CreateConnection();</span><br />
<span style="color:#3333ff;"> userRoleManager.Connection.Open(<span style="color:#ff0000;">GetSCConnectionStringBuilder</span>().ToString());</span></p>
<p><span style="color:#3333ff;"> return userRoleManager;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>And implement a second method, to get us a <span style="color:#3333ff;"><span style="color:#ff0000;">GetSCConnectionStringBuilder </span></span>object.<span style="color:#3333ff;"><span style="color:#ff0000;"><br />
<span style="color:#3333ff;">public static <span style="color:#ff0000;">SCConnectionStringBuilder </span>GetSCConnectionStringBuilder()</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder();</span><br />
<span style="color:#3333ff;"> connectionString.Authenticate = true;</span><br />
<span style="color:#3333ff;"> connectionString.Host = ConfigurationSettings.AppSettings["<span style="font-weight:bold;">K2Server</span>"];</span><br />
<span style="color:#3333ff;"> connectionString.Integrated = true;</span><br />
<span style="color:#3333ff;"> connectionString.IsPrimaryLogin = true;</span><br />
<span style="color:#3333ff;"> connectionString.Port = uint.Parse(ConfigurationSettings.AppSettings["<span style="font-weight:bold;">K2ServerPort</span>"]);</span></span></span></p>
<p><span style="color:#3333ff;"> return connectionString;</span><br />
<span style="color:#3333ff;">}</span></p>
<p><span style="color:#000000;">Basically, this method will read <span style="font-weight:bold;">K2Server </span>and <span style="font-weight:bold;">K2ServerPort </span>keys from your config and use them for connection to K2. You are free to implement it any way you like. Now, when we have those two helper methods, we can finally do:<br />
<span style="color:#3333ff;">UserRoleManager userRoleManager = GetUserRoleManager();</span></span></p>
<p>Using the Role Manager, we will try to get an object representation of the K2 role we are checking against:<br />
<span style="color:#3333ff;">Role role = userRoleManager.GetRole(roleName);</span><br />
<span style="color:#3333ff;">if (role == null)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> throw new Exception(&#8220;Role &#8221; + roleName + &#8221; not found!&#8221;);</span><br />
<span style="color:#3333ff;">}</span></p>
<p>So this piece of code will throw an exception in case the role we are trying to check does not exist. If it exists, our Role object will not be null. Now we need to enumerate the RoleItems within the role. Basically, it will give us all the users (or AD groups) included in this K2 role:<br />
<span style="color:#3333ff;">foreach (RoleItem roleItem in role.Include)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> string currentRoleName = roleItem.Name;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Again, let&#8217;s see what we have so far:<br />
<span style="color:#3333ff;">public static bool CurrentUserBelongsToK2Role(string roleName)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> string loginName = WindowsIdentity.GetCurrent().Name;</span></p>
<p><span style="color:#3333ff;"> UserRoleManager userRoleManager = GetUserRoleManager();</span></p>
<p><span style="color:#3333ff;"> Role role = userRoleManager.GetRole(roleName);</span><br />
<span style="color:#3333ff;"> if (role == null)</span><br />
<span style="color:#3333ff;"> {</span><br />
<span style="color:#3333ff;"> throw new Exception(&#8220;Role &#8221; + roleName + &#8221; not found!&#8221;);</span><br />
<span style="color:#3333ff;"> }</span></p>
<p><span style="color:#3333ff;"> foreach (RoleItem roleItem in role.Include)</span><br />
<span style="color:#3333ff;"> {</span><br />
<span style="color:#3333ff;"> string currentRoleName = roleItem.Name;</span></p>
<p><span style="font-weight:bold;"> // TODO: Implement here</span><br />
<span style="color:#3333ff;"> }</span></p>
<p><span style="color:#3333ff;"> return false;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>So far so good, at least we are now able to enumerate all items within a K2 role! Let&#8217;s keep going and finish the implementation as marked in <span style="font-weight:bold;">bold</span> above.</p>
<p>The <span style="font-weight:bold;">currentRoleName </span>object could be returned to us in the format of <span style="font-weight:bold;">K2:DOMAIN\Name</span>. We need to normalize it to <span style="font-weight:bold;">DOMAIN\Name</span> (i.e. remove the &#8216;K2:&#8217; part).<br />
<span style="color:#3333ff;">if (currentRoleName.IndexOf(&#8216;:&#8217;) &gt; -1)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> currentRoleName = roleItem.Name.Split(&#8216;:&#8217;)[1];</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Now&#8230; the roleItem object we have (in the foreach statement) is of <span style="font-weight:bold;">base</span> type RoleItem. There are two classes which inherit from it &#8211; <span style="font-weight:bold;">UserItem</span> and <span style="font-weight:bold;">GroupItem</span>. This means, the current roleItem could be any of the two, which will help us understand if we are dealing with a single user or an ActiveDirectory group added to the K2 role. Let&#8217;s detect this:<br />
<span style="color:#3333ff;">if (roleItem is UserItem)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> // TODO: Implement</span><br />
<span style="color:#3333ff;">}</span><br />
<span style="color:#3333ff;">else if (roleItem is GroupItem)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> // TODO: Implement</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Now we know when we are dealing with user and when with AD group. We just need to implement both cases. Implementing the UserItem case is as easy as comparing the currentRoleName to the loginName:<br />
<span style="color:#3333ff;">if (currentRoleName.ToLower() == loginName.ToLower())</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> // Found a USER match</span><br />
<span style="color:#3333ff;"> userRoleManager.Connection.Close();</span><br />
<span style="color:#3333ff;"> return true;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Implementing the GroupItem case is a little bit trickier. First, we need to implement a method which will return us a string array of the AD groups the current user belongs to, so we can later compare against them. Here is the code you will need:<br />
<span style="color:#3333ff;">private static string[] GetCurrentUserADGroups()</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> List groups = new List();</span></p>
<p><span style="color:#3333ff;"> // Get the Groups of the current user</span><br />
<span style="color:#3333ff;"> foreach (IdentityReference group in WindowsIdentity.GetCurrent().Groups)</span><br />
<span style="color:#3333ff;"> {</span><br />
<span style="color:#3333ff;"> // Ad the group to the list</span><br />
<span style="color:#3333ff;"> NTAccount ntAcctGroup = group.Translate(typeof(NTAccount)) as NTAccount;</span><br />
<span style="color:#3333ff;"> groups.Add(ntAcctGroup.Value.ToLower());</span><br />
<span style="color:#3333ff;"> }</span></p>
<p><span style="color:#3333ff;"> return groups.ToArray();</span><br />
<span style="color:#3333ff;">}</span></p>
<p>With the help of this method, we can get back to the implementation of the GroupItem case now:<br />
<span style="color:#3333ff;">else if (roleItem is GroupItem)</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> string[] loginNameADGroups = GetCurrentUserADGroups();</span><br />
<span style="color:#3333ff;">}</span></p>
<p>Then, we simply check if the loginNameADGroups contain the currentRoleName string (which in this case is an AD group).<br />
<span style="color:#3333ff;">if (loginNameADGroups.Contains(currentRoleName.ToLower()))</span><br />
<span style="color:#3333ff;">{</span><br />
<span style="color:#3333ff;"> userRoleManager.Connection.Close();</span><br />
<span style="color:#3333ff;"> return true;</span><br />
<span style="color:#3333ff;">}</span></p>
<p>And at the end of our CurrentUserBelongsToK2Role method we just have to add:<br />
<span style="color:#3333ff;">// No match found</span><br />
<span style="color:#3333ff;">userRoleManager.Connection.Close();</span><br />
<span style="color:#3333ff;">return false;</span></p>
<p>And that&#8217;s all! So, let&#8217;s see now how the whole thing looks:<br />
<span style="color:#3366ff;">public static bool CurrentUserBelongsToK2Role(string roleName)</span><br />
<span style="color:#3366ff;">{</span><br />
<span style="color:#3366ff;"> string loginName = WindowsIdentity.GetCurrent().Name;</span></p>
<p><span style="color:#3366ff;"> UserRoleManager userRoleManager = GetUserRoleManager();</span></p>
<p><span style="color:#3366ff;"> Role role = userRoleManager.GetRole(roleName);</span><br />
<span style="color:#3366ff;"> if (role == null)</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> throw new Exception(&#8220;Role &#8221; + roleName + &#8221; not found!&#8221;);</span><br />
<span style="color:#3366ff;"> }</span></p>
<p><span style="color:#3366ff;"> foreach (RoleItem roleItem in role.Include)</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> string currentRoleName = roleItem.Name;</span></p>
<p><span style="color:#3366ff;"> // Is it K2:DOMAIN\Name ?</span><br />
<span style="color:#3366ff;"> if (currentRoleName.IndexOf(&#8216;:&#8217;) &gt; -1)</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> // Get DOMAIN\Name</span><br />
<span style="color:#3366ff;"> currentRoleName = roleItem.Name.Split(&#8216;:&#8217;)[1];</span><br />
<span style="color:#3366ff;"> }</span></p>
<p><span style="color:#3366ff;"> if (roleItem is UserItem)</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> if (currentRoleName.ToLower() == loginName.ToLower())</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> // Found a USER match</span><br />
<span style="color:#3366ff;"> userRoleManager.Connection.Close();</span><br />
<span style="color:#3366ff;"> return true;</span><br />
<span style="color:#3366ff;"> }</span><br />
<span style="color:#3366ff;"> }</span><br />
<span style="color:#3366ff;"> else if (roleItem is GroupItem)</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> string[] loginNameADGroups = GetCurrentUserADGroups();</span></p>
<p><span style="color:#3366ff;"> if (loginNameADGroups.Contains(currentRoleName.ToLower()))</span><br />
<span style="color:#3366ff;"> {</span><br />
<span style="color:#3366ff;"> userRoleManager.Connection.Close();</span><br />
<span style="color:#3366ff;"> return true;</span><br />
<span style="color:#3366ff;"> }</span><br />
<span style="color:#3366ff;"> }</span><br />
<span style="color:#3366ff;"> }</span></p>
<p><span style="color:#3366ff;"> // No match found</span><br />
<span style="color:#3366ff;"> userRoleManager.Connection.Close();</span><br />
<span style="color:#3366ff;"> return false;</span><br />
<span style="color:#3366ff;">}</span></p>
<p>Of course, you can find the whole project attached <a href="http://yankov.us/K2RoleCheck.zip"><span style="font-weight:bold;">here</span></a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=41&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/03/check-if-user-belongs-to-k2-role/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a K2 SmartObject</title>
		<link>http://hyankov.wordpress.com/2009/07/02/how-to-create-a-k2-smartobject/</link>
		<comments>http://hyankov.wordpress.com/2009/07/02/how-to-create-a-k2-smartobject/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:26:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[broker]]></category>
		<category><![CDATA[consume]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[screenshots]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[smart]]></category>
		<category><![CDATA[smartobject]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[workflow]]></category>
		<category><![CDATA[workspace]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/02/how-to-create-a-k2-smartobject</guid>
		<description><![CDATA[How does K2[blackpearl] integrate with other systems? One standard way to do this is through Web Services. And how does K2[blackpearl] integrate with Web Services? It is done through SmartObjects. So we have: K2 SmartObject Web Service Other System &#8220;A K2 SmartObject can encapsulate data that does not currently reside in an existing system, such [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=40&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>How does K2[blackpearl] integrate with other systems? One standard way to do this is through Web Services. And how does K2[blackpearl] integrate with Web Services? It is done through <a href="http://www.k2.com/en/smartobjects.aspx" target="_blank">SmartObjects</a>. So we have: <span style="font-style:italic;font-weight:bold;">K2  SmartObject  Web Service  Other System</span></p>
<p><span class="fullpost"><br />
<span style="font-style:italic;">&#8220;A K2 SmartObject can encapsulate data that does not currently reside in an existing system, such as data about an employee&#8217;s extracurricular activities, his or her family, or hobbies and interests. By using a SmartObject for employee information, all data about an employee is accessed in the same place, and updates are applied to the data at its source. It is important to remember that SmartObjects do not store or cache data. Once created, a SmartObject can be used and reused in a variety of ways; within K2 Designer for Visio, integrated for use in an InfoPath form, a workflow deployed via K2 Studio, in a report, in SharePoint, etc.&#8221;</span></span></p>
<p>SmartObject is all that and also it is the link between K2 and Web Services. So let&#8217;s see step by step how do we consume a Web Service method.</p>
<p><span style="font-weight:bold;">1. Create Web Service</span><br />
First, let&#8217;s create a simple web service which we will be consuming later. For the purposes of the demonstration, it will be as simple as returning you the sum of two values.</p>
<p>I will use Visual Studio 2008 to create a new &#8216;ASP.NET Web Service Application&#8217; project.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/newproject1.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/newproject1.jpg?w=300" border="0" alt="" /></a></p>
<p>Let&#8217;s create the simple method &#8216;Sum&#8217;. See screenshot below:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/code1.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/code1.jpg?w=300" border="0" alt="" /></a></p>
<p>Of course, you should test it first:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/testit.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/testit.jpg?w=300" border="0" alt="" /></a></p>
<p>For the curious, it returned 3 <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Ok, now we need to publish it somewhere in the network and make sure we can access it! Right click the solution, Publish.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/publish1.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/publish1.jpg?w=300" border="0" alt="" /></a></p>
<p>&#8216;Publish&#8217; it somewhere on your local hard drive and make sure you map it in IIS to a virtual directory. You can do that by going into IIS, choose existing site (or create a new one), right click on it -&gt; New Virtual Directory, browse to the path where you Published the service and keep clicking Next.</p>
<p>Let&#8217;s assume you published your service to <a href="http://localhost:86/SampleService/SampleService.asmx" rel="nofollow">http://localhost:86/SampleService/SampleService.asmx</a>, which in the local network (if you have one) maps to <a href="http://192.168.0.1:86/SampleService/SampleService.asmx" rel="nofollow">http://192.168.0.1:86/SampleService/SampleService.asmx</a>.</p>
<p>We are done with the service, it&#8217;s in the network, it works, it is ready to be registered as a service instance.</p>
<p><span style="font-weight:bold;">2. From K2 Workspace add it to Dynamic Web Service</span><br />
Ok, now we have to add it to the &#8216;Dynamic Web Services&#8217; list. Open your K2 Workspace. Go to <span style="font-style:italic;font-weight:bold;">Management -&gt; Management Console -&gt; Expand the servername -&gt; SmartObjects -&gt; Services -&gt; Dynamic Web Service.</span><br />
<a href="http://hyankov.files.wordpress.com/2009/07/dynamicwebservice.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/dynamicwebservice.jpg?w=300" border="0" alt="" /></a></p>
<p>Click on the Add button and populate the URL field.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/registerservice.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/registerservice.jpg?w=300" border="0" alt="" /></a></p>
<p>Click Next. In the next screen set names to something that makes sense to you and click Save. Let&#8217;s call it &#8216;Sample Service&#8217;.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/serverinstance.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/serverinstance.jpg?w=300" border="0" alt="" /></a></p>
<p>You have now registered a service instance. Let&#8217;s verify that by going to the K2 server and opening <span style="font-weight:bold;">C:\Program Files\K2 blackpearl\ServiceBroker</span> (or C:\Program Files <span style="font-weight:bold;">(x86)</span>\K2 blackpearl\ServiceBroker) and run <span style="font-weight:bold;">BrokerManagement.exe</span>. On the first screen, click on &#8216;Configure Services&#8217;.<br />
Under <span style="font-style:italic;font-weight:bold;">services -&gt; DynamicWebService -&gt; serviceinstances</span> there should be an instance with a name &#8216;<span style="font-weight:bold;">SampleService</span>&#8216;.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">3. Create SmartObject</span><br />
We are good to create a SmartObject around it now. Start a new instance of Visual Studio and create a new K2 SmartObject project.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/sampleservicesmartobject.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/sampleservicesmartobject.jpg?w=300" border="0" alt="" /></a></p>
<p>The first thing you do is switch to <span style="font-weight:bold;">Advanced mode</span>.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/advancedmode.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/advancedmode.jpg?w=300" border="0" alt="" /></a></p>
<p>Then Remove All methods that were created for you. We will start from scratch.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/removeall.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/removeall.jpg?w=300" border="0" alt="" /></a></p>
<p>Then click on +Add and run the wizard that shows up in Advanced mode (it&#8217;s a checkbox on the first page).<br />
<a href="http://hyankov.files.wordpress.com/2009/07/advancedmode2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/advancedmode2.jpg?w=300" border="0" alt="" /></a></p>
<p>Name the method Sum, make it Read type.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/methodsum.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/methodsum.jpg?w=300" border="0" alt="" /></a></p>
<p>In the next screen, Configure Method Parameters, we will add the two parameters that we have to pass to the method &#8211; intA and intB. Make them &#8216;Number&#8217;s.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/numbers.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/numbers.jpg?w=300" border="0" alt="" /></a></p>
<p>At the end, it should look like this:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/numbers2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/numbers2.jpg?w=300" border="0" alt="" /></a></p>
<p>Click Next. On the next screen you have to select the Service Method we will be executing. This is easy. First click Add, to start adding a service method call to the SmartObject. A new popup will show. There is a field &#8216;Service Object Method&#8217; and next to it there is a &#8216;&#8230;&#8217; button. Click on the button. It will open the Context browser. Browse through <span style="font-weight:bold;font-style:italic;">ServiceObjects Server -&gt; Sample Service -&gt; Sum -&gt; Read</span>.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/servicemethod.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/servicemethod.jpg?w=300" border="0" alt="" /></a></p>
<p>Click Add in the Context Browser. You will see:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/addserviceobj.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/addserviceobj.jpg?w=300" border="0" alt="" /></a></p>
<p>We need to map some fields now. See the &#8216;a&#8217; and &#8216;b&#8217; input properties? They are the web service method input parameters. We have to &#8216;bind&#8217; them to the intA and intB fields we created for the SmartObject.</p>
<p>Click on the first one (&#8216;a&#8217;), click &#8216;Assign&#8217; button and a small pop up will appear. Set &#8216;Map to&#8217; to &#8216;SmartObject Method Parameter&#8217; and from the second dropdown select &#8216;intA&#8217;.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/bind.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/bind.jpg?w=300" border="0" alt="" /></a></p>
<p>Then click ok and do the same thing for &#8216;b&#8217;, but select &#8216;intB&#8217; instead.  For &#8216;ReturnValue&#8217; &#8211; click on it, Assign, set &#8216;Map To&#8217; to SmartObject Property (i.e. you are storing the result in a property of the SmartObject). Then click Create.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/create2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/create2.jpg?w=300" border="0" alt="" /></a></p>
<p>You should end up with:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/endresult.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/endresult.jpg?w=300" border="0" alt="" /></a><br />
Click OK and finish the wizard.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/finish.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/finish.jpg?w=300" border="0" alt="" /></a></p>
<p>Make sure you name your SmartObject properly.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/rename.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/rename.jpg?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">4. Deploy</span><br />
Right click the solution and do Rebuild. It should compile with no errors. Let&#8217;s deploy the SmartObject to our K2 Server. Right click the project -&gt; Deploy. Follow the wizard (Next, Finish) and your SmartObject should be deployed.</p>
<p><span style="font-weight:bold;">5. Test</span><br />
Let&#8217;s test your SmartObject. Log into the K2 server and go back to <span style="font-weight:bold;">C:\Program Files (x86)\K2 blackpearl\ServiceBroker</span>. Run the file <span style="font-weight:bold;">SmartObject Service Tester.exe</span>.</p>
<p>Expand the SmartObjects section, find your SampleServiceSmartObject, expand it until you see the Sum method.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/summethod.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/summethod.jpg?w=300" border="0" alt="" /></a></p>
<p>Right click on it, Execute method. Populate the input fields and click &#8216;Sum&#8217; button. Promptly, you should see the result displayed.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/executemethod.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/executemethod.jpg?w=300" border="0" alt="" /></a></p>
<p>We just invoked the SmartObject, which talked to the WebService, retrieved result for us and was visualized in the test utility. Everything works perfectly, your SmartObject is ready to be consumed from a workflow!</p>
<p><span style="font-weight:bold;">6. Consume in Workflow</span><br />
Create a new K2 Process Project in Visual Studio. I will reuse the K2 solution we already have and just add the new project to it.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/process.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/process.jpg?w=300" border="0" alt="" /></a></p>
<p>From the Toolbox, drag and drop a new SmartObject event. On the second page, Wizard will prompt you for SmartObject Method. Browse to our Sum method in the SampleServiceSmartObject.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/summethod2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/summethod2.jpg?w=300" border="0" alt="" /></a><br />
Click Add. It should look like this:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/sum3.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/sum3.jpg?w=300" border="0" alt="" /></a></p>
<p>On the next screen, you have to provide values for the SmartObject input properties. This could be K2 DataFields from your process, or actual hardcoded sample values. For the purpose of the demo, we will just bind them to &#8217;2&#8242; and &#8217;54&#8242;. Select the property, click Assign button, set value, click ok. It should look like this:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/values.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/values.jpg?w=300" border="0" alt="" /></a></p>
<p>On the next screen, we have to bind the return result to something. Let&#8217;s bind it to a DataField in the process which we will create. Click on the ReturnValue, click &#8216;Assign&#8217;, in the popup click on the &#8216;&#8230;&#8217; button which will open the Context Browser. In this browser, either select already existing DataField, or create a new one on the fly (right click -&gt; create). Make sure the field is Integer (for this demo). Select it, click &#8216;Add&#8217;, then &#8216;Ok&#8217; in the pop up.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/returnmapping.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/returnmapping.jpg?w=300" border="0" alt="" /></a></p>
<p>It should look like:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/sumresult.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/sumresult.jpg?w=300" border="0" alt="" /></a></p>
<p>Click finish. You just finished adding a SmartObject event to your workflow. After this event is executed, you will have the value of &#8216;a&#8217; + &#8216;b&#8217; in the SumValue data field. I.e. you are consuming the SmartObject (and hence the Web Service).<br />
<a href="http://hyankov.files.wordpress.com/2009/07/workflow.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/workflow.jpg?w=300" border="0" alt="" /></a></p>
<p>Now you just need to finish the rest of the workflow <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span style="font-weight:bold;">7. Change the URL of the service</span><br />
What if the address of your Web Service changes? Simple, go to the K2 server and open the C:\Program Files (x86)\K2 blackpearl\ServiceBroker folder. Run the BrokerManagement.exe app. On the first screen, click on &#8216;Configure Services&#8217;.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/configureservices.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/configureservices.jpg?w=300" border="0" alt="" /></a></p>
<p>Find your service instance again:<br />
<a href="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg?w=300" border="0" alt="" /></a><br />
Right click on it -&gt; Configure Service. It will open a pop up. There you can change the URL field and click Save.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/configureservice.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/configureservice.jpg?w=300" border="0" alt="" /></a></p>
<p>And that&#8217;s it, your service instance is now pointing to the right URL.</p>
<p>Basically that&#8217;s all. Now you know how to consume web services from your K2 Workflows, utilizing SmartObjects!</p>
<p>Hope this helps!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=40&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/02/how-to-create-a-k2-smartobject/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/newproject1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/code1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/testit.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/publish1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/dynamicwebservice.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/registerservice.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/serverinstance.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/sampleservicesmartobject.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/advancedmode.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/removeall.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/advancedmode2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/methodsum.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/numbers.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/numbers2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/servicemethod.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/addserviceobj.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/bind.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/create2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/endresult.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/finish.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/rename.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/summethod.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/executemethod.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/process.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/summethod2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/sum3.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/values.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/returnmapping.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/sumresult.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/workflow.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/configureservices.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/manageservices.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/configureservice.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>SharePoint bug tracking</title>
		<link>http://hyankov.wordpress.com/2009/07/02/sharepoint-bug-tracking/</link>
		<comments>http://hyankov.wordpress.com/2009/07/02/sharepoint-bug-tracking/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 08:39:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[screenshots]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[track]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/02/sharepoint-bug-tracking</guid>
		<description><![CDATA[So you have this SharePoint project you are working on&#8230; And as with any project, you need a bug tracker in order to communicate properly with the QAs and BAs in the company. What do you use? OnTime? Mantis? Bugzilla? Why not SharePoint itself? It&#8217;s already (presumably) set up for you, users are familiar with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=39&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>So you have this SharePoint project you are working on&#8230; And as with any project, you need a bug tracker in order to communicate properly with the QAs and BAs in the company. What do you use? <a href="http://www.axosoft.com/" target="_blank">OnTime</a>? <a href="http://www.mantisbt.org/" target="_blank">Mantis</a>? <a href="http://www.bugzilla.org/" target="_blank">Bugzilla</a>?</p>
<p>Why not SharePoint itself? It&#8217;s already (presumably) set up for you, users are familiar with it and you are only couple of steps away from setting up your own Issue Tracker.</p>
<p><span class="fullpost"><br />
To get it up and running, here is what you should do, step by step:<br />
1. Open your SharePoint web site as admin</span></p>
<p>2. Click on &#8216;View All Site Content&#8217; (usually top left) or open <a href="http://server:port/_layouts/viewlsts.aspx" rel="nofollow">http://server:port/_layouts/viewlsts.aspx</a></p>
<p>3. Click on &#8216;Create&#8217; to create a new list (shortcut: <a href="http://server:port/_layouts/create.aspx" rel="nofollow">http://server:port/_layouts/create.aspx</a>)<br />
<a href="http://hyankov.files.wordpress.com/2009/07/create.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/create.jpg?w=300" border="0" alt="" /></a></p>
<p>4. From the &#8216;Tracking&#8217; column select &#8216;Issue Tracking&#8217;<br />
<a href="http://hyankov.files.wordpress.com/2009/07/issuetracking.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/issuetracking.jpg?w=300" border="0" alt="" /></a></p>
<p>5. Type in the name and description of the list where issues will be tracked<br />
<a href="http://hyankov.files.wordpress.com/2009/07/issuetrackingform.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/issuetrackingform.jpg?w=284" border="0" alt="" /></a><br />
You may want to select &#8216;Yes&#8217; on &#8216;Send e-mail when ownership is assigned&#8217;, to send emails to the users assigned to issues.</p>
<p>6. Click &#8216;Create&#8217; button and your bug tracker is created. You should see a list with the name you have given on step 5. This is the tracker, open it. Click &#8216;New Item&#8217; to see the default fields and their values you get.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/newitem.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/newitem.jpg?w=290" border="0" alt="" /></a></p>
<p>7. Time to customize according to your needs. Go to the List Settings of your issue tracking list.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/listsettings.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/listsettings.jpg?w=300" border="0" alt="" /></a></p>
<p>8. Scroll down to the Columns section. You will want to modify the highlighted columns &#8211; Issue Status, Priority and Category, for starter.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/columns.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/columns.jpg?w=300" border="0" alt="" /></a></p>
<p>9. Click on any of them, let&#8217;s say &#8216;Issue Status&#8217;. Scroll down to the &#8216;Additional Column Settings&#8217;<br />
<a href="http://hyankov.files.wordpress.com/2009/07/columnsettings.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/columnsettings.jpg?w=234" border="0" alt="" /></a></p>
<p>You can now change the possible statuses your issues may have. For example, you may want to add &#8216;Acknowledged&#8217;, &#8216;Postponed&#8217;, &#8216;Invalid&#8217;, &#8216;Cannot fix&#8217;, etc&#8230; You may also change the default value or make the field required (a smart choice). When you are happy with your changes, click Ok.</p>
<p>10. Do the same for Category and Priority.</p>
<p>11. You can extend your tracker further, by adding extra columns. Let&#8217;s say, Product (as you may be working on different products at the same time) or Version (as your product may have many production versions). To do this, go to the Settings of the list again (as in step 7). Scroll down to columns and click Create Column.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/createcolumn.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/createcolumn.jpg?w=300" border="0" alt="" /></a></p>
<p>12. Type in the name of your column and select its type. In this case, I will name it &#8216;Product Version&#8217; and make it a dropdown list.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/productversion.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/productversion.jpg?w=300" border="0" alt="" /></a></p>
<p>13. Make the column required (if you want to), specify the available choices and select the type of the control (dropdown, radio buttons or check boxes).<br />
<a href="http://hyankov.files.wordpress.com/2009/07/newcolumn.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/newcolumn.jpg?w=225" border="0" alt="" /></a><br />
Then click Ok and you are all set.</p>
<p>14. Let&#8217;s test your bug tracker. Go to the list and create a new item<br />
<a href="http://hyankov.files.wordpress.com/2009/07/newitem2.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/newitem2.jpg?w=300" border="0" alt="" /></a></p>
<p>15. Fill all the fields you want to and click Ok. You have now logged a new Issue.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/createditem.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/createditem.jpg?w=300" border="0" alt="" /></a></p>
<p>16. To customize your tracker further, you may want to create new Views, which sort and arrange the items in categories, assignees and what not<br />
<a href="http://hyankov.files.wordpress.com/2009/07/views.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/views.jpg?w=247" border="0" alt="" /></a></p>
<p>17. You may need to add users (give permissions) to the site or the list.</p>
<p>Now you have your own tracker, embedded in your SharePoint environment. Hope this was helpful!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=39&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/02/sharepoint-bug-tracking/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/create.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/issuetracking.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/issuetrackingform.jpg?w=284" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/newitem.jpg?w=290" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/listsettings.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/columns.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/columnsettings.jpg?w=234" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/createcolumn.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/productversion.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/newcolumn.jpg?w=225" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/newitem2.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/createditem.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/views.jpg?w=247" medium="image" />
	</item>
		<item>
		<title>SharePoint Development tools list</title>
		<link>http://hyankov.wordpress.com/2009/07/01/sharepoint-development-tools-list/</link>
		<comments>http://hyankov.wordpress.com/2009/07/01/sharepoint-development-tools-list/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:35:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SharePoint Manager 2007]]></category>
		<category><![CDATA[SharePoint Timer Scheduler]]></category>
		<category><![CDATA[STSDEV]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[U2U CAML Query Builder]]></category>
		<category><![CDATA[WSPBuilder]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/01/sharepoint-development-tools-list</guid>
		<description><![CDATA[SharePoint development is not always as straight-forward as we all want it to be. However, there are a lot of tools which can make our job easier. Here is a list of some of our favorite tools for SharePoint development: SharePoint Manager 2007 &#8220;The SharePoint Manager 2007 is a SharePoint object model explorer. It enables [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=38&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>SharePoint development is not always as straight-forward as we all want it to be. However, there are a lot of tools which can make our job easier. Here is a list of some of our favorite tools for SharePoint development:</p>
<p><span class="fullpost"><br />
<a href="http://www.codeplex.com/spm"><span style="font-weight:bold;">SharePoint Manager 2007</span></a><br />
<span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel" style="font-style:italic;">&#8220;The SharePoint Manager 2007 is a SharePoint object model explorer. It enables you to browse every site on the local farm and view every property. It also enables you to change the properties (at your own risk). This is a very powerfull tool for developers that like to know what the SharePoint holds of secrets. &#8220;</span></span></p>
<p><a href="http://www.codeplex.com/stsdev"><span style="font-weight:bold;">STSDEV: Simple Tools for SharePoint 2007 Development</span></a><br />
<span style="font-style:italic;">&#8220;</span><span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel"><strong>STSDEV</strong><span style="font-style:italic;"> is a </span><em>proof-of-concept</em><span style="font-style:italic;"> utility application which demonstrates how to generate Visual Studio project files and solution files to facilitate the development and deployment of templates and components for the SharePoint 2007 platform including Windows SharePoint Services 3.0 (WSS) and Microsoft Office SharePoint Server 2007 (MOSS).&#8221;</span></span></p>
<p><a href="http://www.codeplex.com/wspbuilder"><span style="font-weight:bold;">WSPBuilder</span></a><br />
<span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel"><span style="font-style:italic;">&#8220;A SharePoint Solution Package (WSP) creation tool for WSS 3.0 &amp; MOSS 2007&#8243;</span></span></p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7bf65b28-06e2-4e87-9bad-086e32185e68&amp;displaylang=en"><span style="font-weight:bold;">Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions, Version 1.2</span></a><br />
<span style="font-style:italic;">&#8220;Tools for developing custom SharePoint applications: Visual Studio project templates for Web Parts, site definitions, and list definitions; and a stand-alone utility program, the SharePoint Solution Generator.</span>&#8220;</p>
<p><a href="http://www.u2u.net/res/Tools/CamlQueryBuilder.aspx"><span style="font-weight:bold;">U2U CAML Query Builder</span></a><br />
<span style="font-style:italic;">&#8220;CAML (Collaborative Application Markup Language) is an XML-based query language that helps you querying, building and customizing Web sites based on Windows SharePoint Services. The XML elements define various aspects of a WSS site. The tool will help you build, test and execute your CAML Queries. &#8220;</span></p>
<p>I don&#8217;t think anybody wants to write CAML Queries &#8216;by hand&#8217;</p>
<p><a href="http://www.codeplex.com/SPTimerScheduler"><span style="font-weight:bold;">SharePoint Timer Scheduler</span></a><br />
<span style="font-style:italic;">&#8220;Sharepoint Timer Scheduler gives you a way of running your Timer Job from a list in the Root Web of your Sharepoint site. Excellent way of giving Site Administrators access to Timer Jobs so they can be run immediately or rescheduled. No need to code custom SPJobDefinition classes.&#8221;</span></p>
<p>Basically, this is a &#8216;tool&#8217; which allows you to reschedule timer jobs without the need to redeploy a solution! Great!</p>
<p><a style="font-weight:bold;" href="http://blog.myitechnology.com/2009/06/fixing-feature-guid-for-list-template.html">Pako Simeonov&#8217;s Tool</a><br />
Pako Simeonov wrote a great tool which fixes errors of the kind <span style="color:#cc0000;">&#8216;Feature {Guid} for list template is not installed in this farm. The operation could not be completed&#8217;<br />
</span><span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel" style="font-weight:bold;"><span style="color:#cc0000;"><br />
</span></span><span style="font-weight:bold;">What are your favorite tools?</span><span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel"><span style="color:#cc0000;"><br />
</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=38&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/01/sharepoint-development-tools-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint DateTime Format and Regional Settings</title>
		<link>http://hyankov.wordpress.com/2009/07/01/sharepoint-datetime-format-and-regional-settings/</link>
		<comments>http://hyankov.wordpress.com/2009/07/01/sharepoint-datetime-format-and-regional-settings/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 14:53:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[Regional Settings]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[site settings]]></category>
		<category><![CDATA[ToShortDateString]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/07/01/sharepoint-datetime-format-and-regional-settings</guid>
		<description><![CDATA[Now, how exactly do you control the DateTime string representation and formatting in a SharePoint application? Normally, in an ASP.NET Web Application, it depends on the Regional Settings (Control Panel -&#62; Regional and Language Options) of the user running the application pool of the site. Unless you override the Culture options in the code. So [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=37&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Now, how exactly do you control the <span style="font-weight:bold;">DateTime </span>string representation and formatting in a SharePoint application?</p>
<p>Normally, in an ASP.NET Web Application, it depends on the Regional Settings (<span style="font-style:italic;">Control Panel -&gt; Regional and Language Options</span>) of the <span style="font-weight:bold;">user running the application pool of the site</span>. Unless you override the Culture options in the code.</p>
<p><span class="fullpost"><br />
So when I tried to &#8216;localize&#8217; the DateTime representation for my SharePoint site, by changing the app pool user&#8217;s Regional settings, at first I was surprised it didn&#8217;t do the job. DateTime was still shown in the default en-US format.</span></p>
<p>This means SharePoint overrided the Regional settings of its application pool user. It took me a couple of minutes before I realized that for SharePoint applications, the DateTime formatting is controlled by <span style="font-weight:bold;">opening the site -&gt; Site Actions -&gt; Site Settings -&gt; Site Administration (column) -&gt; Regional Settings</span><br />
<a href="http://hyankov.files.wordpress.com/2009/07/regionalsettings.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/regionalsettings.jpg?w=300" border="0" alt="" /></a></p>
<p>There, you have the option to fine tune the regional settings for the site, which will also affect the DateTime formatting.<br />
<a href="http://hyankov.files.wordpress.com/2009/07/finetuneregionalsettings.jpg"><img src="http://hyankov.files.wordpress.com/2009/07/finetuneregionalsettings.jpg?w=300" border="0" alt="" /></a></p>
<p>After setting it to the one you desire, you save the settings and next time you open the site, DateTime will be formatted according to the locale you have selected.</p>
<p>Hope this helps!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=37&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/07/01/sharepoint-datetime-format-and-regional-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/07/regionalsettings.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/07/finetuneregionalsettings.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>Append new line to SPFieldMultiLineText in SharePoint</title>
		<link>http://hyankov.wordpress.com/2009/06/30/append-new-line-to-spfieldmultilinetext-in-sharepoint/</link>
		<comments>http://hyankov.wordpress.com/2009/06/30/append-new-line-to-spfieldmultilinetext-in-sharepoint/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 14:05:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[AllowUnsafeUpdates]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[GetFieldValueAsHtml]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[new line]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SPFieldMultiLineText]]></category>
		<category><![CDATA[SPListItem]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/30/append-new-line-to-spfieldmultilinetext-in-sharepoint</guid>
		<description><![CDATA[Do you have a multiline text box field in your SharePoint site and ever wondered how to append a new line to it? Are you confused whether you should use \r\n, Environment.NewLine or perhaps even #xD #xA to mark a line break? Allow me to save you the time and give you a straight answer. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=36&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Do you have a multiline text box field in your SharePoint site and ever wondered how to <span style="font-weight:bold;">append a new line</span> to it? Are you confused whether you should use <span style="font-weight:bold;">\r\n</span>, <span style="font-weight:bold;">Environment.NewLine</span> or perhaps even <span style="font-weight:bold;">#xD #xA</span> to mark a line break? Allow me to save you the time and give you a straight answer.</p>
<p><span class="fullpost"><br />
The first thing you have to do is convert the SPListItem that represents your field into <span style="color:#3333ff;font-size:85%;"></span>SPFieldMultiLineText.<span style="color:#3333ff;font-size:85%;"><br />
SPFieldMultiLineText multilineField<br />
= item.Fields.GetField(COLUMN_NAME) as SPFieldMultiLineText;</span></span></p>
<p>Then you can use its GetFieldValueAsHtml method to get the value in the form of HTML (which will preserve the multiple lines):<br />
<span style="color:#3333ff;font-size:85%;">string text = multilineField.GetFieldValueAsHtml(item[COLUMN_NAME], item);</span></p>
<p>You should use &#8216;&lt;br/&gt;&#8217; as a line break:<br />
<span style="color:#3333ff;font-size:85%;">string sharePointNewLine = &#8220;&lt;br/&gt;&#8221;;</span><br />
<span style="color:#3333ff;font-size:85%;">text = text<br />
+ sharePointNewLine + sharePointNewLine<br />
+ &#8220;Appended Text:&#8221; + sharePointNewLine<br />
+ &#8220;This text is appended on a new line!&#8221;;</span></p>
<p>And after that you just update your item:<br />
<span style="color:#3333ff;font-size:85%;">this.Web.AllowUnsafeUpdates = true;<br />
item[COLUMN_NAME] = text;<br />
item.Update();<br />
this.Web.AllowUnsafeUpdates = false;</span></p>
<p>So if the original text in the field was &#8220;<span style="color:#006600;">Test test test</span>&#8220;, after executing this code, it would read:<br />
<span style="font-weight:bold;color:#009900;">Test test test</span></p>
<p><span style="font-weight:bold;color:#009900;">Appended Text:</span><br />
<span style="font-weight:bold;color:#009900;">This text is appended on a new line!</span></p>
<p>Simple? As long as you remember that text should be retrieved as HTML and you should use &#8216;&lt;br/&gt;&#8217; as a line break, yes.</p>
<p>Here is the full code snippet, ready to use:<br />
<span style="color:#3333ff;font-size:85%;">public void AppendTextToMultiline(SPListItem item)<br />
{<br />
string COLUMN_NAME = &#8220;Multiline Column Name&#8221;;<br />
string sharePointNewLine = &#8220;&lt;br/&gt;&#8221;;<br />
SPFieldMultiLineText multilineField = item.Fields.GetField(COLUMN_NAME) as SPFieldMultiLineText;</span></p>
<p>if (multilineField != null)<br />
{<br />
// Get the field value as HTML<br />
string text = multilineField.GetFieldValueAsHtml(item[COLUMN_NAME], item);</p>
<p>// Append the text<br />
text = text<br />
+ sharePointNewLine + sharePointNewLine<br />
+ &#8220;Appended Text:&#8221; + sharePointNewLine<br />
+ &#8220;This text is appended on a new line!&#8221;;</p>
<p>this.Web.AllowUnsafeUpdates = true;<br />
item[COLUMN_NAME] = text;<br />
item.Update();<br />
this.Web.AllowUnsafeUpdates = false;<br />
}<br />
}</p>
<p>Hope this helps!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=36&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/30/append-new-line-to-spfieldmultilinetext-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>Beware using GetFieldValueAsHtml or GetFormattedValue with DateTime fields</title>
		<link>http://hyankov.wordpress.com/2009/06/29/beware-using-getfieldvalueashtml-or-getformattedvalue-with-datetime-fields/</link>
		<comments>http://hyankov.wordpress.com/2009/06/29/beware-using-getfieldvalueashtml-or-getformattedvalue-with-datetime-fields/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 09:47:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[GetFieldValueAsHtml]]></category>
		<category><![CDATA[GetFormattedValue]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[local time]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SPListItem]]></category>
		<category><![CDATA[time zone]]></category>
		<category><![CDATA[UTC]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/29/beware-using-getfieldvalueashtml-or-getformattedvalue-with-datetime-fields</guid>
		<description><![CDATA[Watch out when using GetFieldValueAsHtml or GetFormattedValue with SharePoint DateTime fields! They both expect the value to be in UTC! However, SPListItem[FieldName] returns its value in Local Time zone and marks it as Unspecified. Basically, what you have to do prior to calling one of the two methods above is make sure your time is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=34&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Watch out when using <span style="font-weight:bold;">GetFieldValueAsHtml </span>or <span style="font-weight:bold;">GetFormattedValue</span> with SharePoint DateTime fields! <span style="color:#ff0000;">They both expect the value to be in UTC</span>! However, SPListItem[FieldName] returns its value in Local Time zone and marks it as Unspecified.</p>
<p><span class="fullpost"><br />
Basically, what you have to do prior to calling one of the two methods above is make sure your time is in UTC:</span></p>
<p>DateTime localTime = (DateTime)listItem["SomeDateTime"];<br />
DateTime universalTime = this.Web.RegionalSettings.TimeZone.LocalTimeToUTC(localTime);<br />
string correctlyConverted = listItem["SomeDateTime"].GetFieldValueAsHtml(universalTime);</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=34&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/29/beware-using-getfieldvalueashtml-or-getformattedvalue-with-datetime-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>The right way to SPWeb.EnsureUser in SharePoint</title>
		<link>http://hyankov.wordpress.com/2009/06/09/the-right-way-to-spweb-ensureuser-in-sharepoint/</link>
		<comments>http://hyankov.wordpress.com/2009/06/09/the-right-way-to-spweb-ensureuser-in-sharepoint/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 09:49:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[access denied]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[EnsureUser]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[RunWithElevatedPrivileges]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[SPSite]]></category>
		<category><![CDATA[SPUser]]></category>
		<category><![CDATA[SPWeb]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/09/the-right-way-to-spweb-ensureuser-in-sharepoint</guid>
		<description><![CDATA[At some point of time you may need to call (SPWeb).EnsureUser from your custom SharePoint web application. But this method can not be called by everyone, as it requires some high level permissions. You may also get an error similar to this one: Your solution is to wrap the EnsureUser within RunWithElevatedPrivileges call. However, there [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=28&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>At some point of time you may need to call <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx">(SPWeb).EnsureUser</a> from your custom SharePoint web application. But this method can not be called by everyone, as it requires some high level permissions. You may also get an error similar to this one:<br />
<a href="http://hyankov.files.wordpress.com/2009/06/error.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/error.jpg?w=300" border="0" alt="" /></a></p>
<p><span class="fullpost"><br />
Your solution is to wrap the EnsureUser within <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx">RunWithElevatedPrivileges</a> call. However, there is a big catch. If you use instances of <span style="font-weight:bold;">SPSite</span> or <span style="font-weight:bold;">SPWeb</span>, obtained prior to the <span style="font-weight:bold;">RunWithElevatedPrivileges</span> block, it won&#8217;t work as expected because they are already associated to a non-elevated security context.</span></p>
<p>To illustrate it with code, here is <span style="font-weight:bold;color:#ff0000;">WRONG </span>usage of RunWithElevatedPrivileges:<br />
<span style="color:#666666;">SPWeb</span> <span style="font-weight:bold;">web </span>= <span style="font-style:italic;">[... somehow obtained here...]</span>;</p>
<p><span style="color:#666666;">SPSecurity</span>.RunWithElevatedPrivileges(<span style="color:#3333ff;">delegate</span>()<br />
{<br />
<span style="font-weight:bold;color:#009900;"> // NOTE: Wrong, do not use</span><br />
<span style="color:#666666;">SPUser</span> someUser = <span style="font-weight:bold;">web</span>.EnsureUser(<span style="font-weight:bold;">web</span>.CurrentUser.LoginName);<br />
});</p>
<p>And here is a <span style="font-weight:bold;color:#000099;">CORRECT </span>one:<br />
<span style="color:#666666;">SPWeb</span> <span style="font-weight:bold;">web </span>= <span style="font-style:italic;">[... somehow obtained here...]</span>;</p>
<p><span style="color:#666666;">SPSecurity</span>.RunWithElevatedPrivileges(<span style="color:#3333ff;">delegate</span>()<br />
{<br />
<span style="color:#3333ff;">using </span>(<span style="color:#666666;">SPSite </span><span style="font-weight:bold;">elevatedSite </span>= <span style="color:#3333ff;">new </span><span style="color:#666666;">SPSite</span>(<span style="font-weight:bold;">web</span>.Site.ID))<br />
{<br />
<span style="color:#666666;">SPWeb </span><span style="font-weight:bold;">elevatedWeb </span>= <span style="font-weight:bold;">elevatedSite</span>.OpenWeb(<span style="font-weight:bold;">web</span>.ID);<br />
<span style="color:#666666;">SPUser</span> someUser = <span style="font-weight:bold;">elevatedWeb</span>.EnsureUser(<span style="font-weight:bold;">web</span>.CurrentUser.LoginName);<br />
}<br />
});</p>
<p>Basically we used the IDs of the Web and Site objects,  obtained prior to the elevated block, and used them to create Site and Web object within the elevated context.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=28&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/09/the-right-way-to-spweb-ensureuser-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/06/error.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>SPTimerScheduler for SharePoint Improvement</title>
		<link>http://hyankov.wordpress.com/2009/06/08/sptimerscheduler-for-sharepoint-improvement/</link>
		<comments>http://hyankov.wordpress.com/2009/06/08/sptimerscheduler-for-sharepoint-improvement/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 12:00:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[schedule]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[sptimerscheduler]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/08/sptimerscheduler-for-sharepoint-improvement</guid>
		<description><![CDATA[At some point of time, you will need to create a Timer Job (scheduled task) for your custom SharePoint web solution. For example, you may need it to synchronize two systems. Out of the box, you can create a SharePoint timer job, by inheriting the SPJobDefinition class and then creating a timer job installer, by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=27&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>At some point of time, you will need to create a Timer Job (scheduled task) for your custom SharePoint web solution. For example, you may need it to synchronize two systems.</p>
<p>Out of the box, you can create a SharePoint timer job, by inheriting the SPJobDefinition class and then creating a timer job installer, by inheriting SPFeatureReceiver. What this basically does is, during the activation of your feature, the installer will kick in and add your timer job to SharePoint timer jobs list. On deactivation of the  feature, the timer job will be &#8216;uninstalled&#8217;. This is associated to a huge inconvenience &#8211; you can&#8217;t change the schedule of your task, unless you change your source code and redeploy. In a production environment this may cause a big stir.</p>
<p><span class="fullpost"><br />
This is where you can use <a href="http://www.codeplex.com/SPTimerScheduler">SPTimerScheduler</a>! It is really convenient and easy to install. After deploying the solution and activating the feature, you get a &#8216;TimerJobSchedule&#8217; list, where you can define all your timer jobs. You just &#8216;point&#8217; to the assembly, class and method you want to execute, pass constructor parameters (optional) and you are done! It allows for simple and easy task (re)scheduling, which is generally why you want to use this solution in the first place.</span></p>
<p><span style="color:#cc0000;">If there is one nice thing about the native SharePoint timer jobs, it is the fact that if your code throws an exception during execution, it will be logged by the SharePoint timer service in the Event Log. This is missing from </span><span style="font-weight:bold;color:#cc0000;">SPTimerScheduler</span><span style="color:#cc0000;">!</span></p>
<p><span style="color:#333399;">The purpose of this article is to show you how to extend this custom solution functionality so you can see what the error was, if any.</span></p>
<p>First, you need to download the source code of SPTimerScheduler from <a href="http://sptimerscheduler.codeplex.com/SourceControl/ListDownloadableCommits.aspx">here</a>. As of right now, the latest release is 1.1.0.0.</p>
<p>After you download the source, open SharePointerTimerJobScheduler.sln in Visual Studio. It may prompt you to remove the version control associated to the project, to which you agree.</p>
<p>We will start by adding one more column to the &#8216;TimerJobSchedule&#8217; list, which will store the latest Exception message. Please note that the project stores the list template as TimerJobSchedule.stp file, which you can not edit directly. Generally, what you have to do is import the stp file to SharePoint, create an instance of this list type, edit it by adding one more column &#8211; LastExceptionMessage (multiline, plain) and then export it again. Overwrite the old stp file with the newly exported one. Here are detailed instructions:</p>
<p>1) Go to your SharePoint web site -&gt; Site Actions -&gt; Site Settings. Under &#8216;Galleries&#8217;, click on &#8216;List Templates&#8217;.<br />
<a href="http://hyankov.files.wordpress.com/2009/06/listtemplates.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/listtemplates.jpg?w=300" border="0" alt="" /></a></p>
<p>2) Click Upload button -&gt; &#8220;Upload Document&#8221;<br />
<a href="http://hyankov.files.wordpress.com/2009/06/uploaddocument.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/uploaddocument.jpg?w=300" border="0" alt="" /></a></p>
<p>3) Browse for &#8220;12\TEMPLATE\FEATURES\SharePointerTimerJobScheduler\TimerJobSchedule.stp&#8221; file from the source code and upload it.</p>
<p>4) Now you have added the SPTimerScheduler as a type of a custom list. Create a new instance of it. Click on &#8216;Create&#8217; and under &#8216;Custom Lists&#8217; you should see &#8216;TimerJobSchedule&#8217;. Click on it.<br />
<a href="http://hyankov.files.wordpress.com/2009/06/timerjobschedule.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/timerjobschedule.jpg?w=300" border="0" alt="" /></a></p>
<p>5) Give the list instance a name and click Create. The go to the settings of the list and under &#8216;Columns&#8217; click &#8216;Create column&#8217; link.</p>
<p>6) Name the column &#8216;LastExceptionMessage&#8217; and make it of type &#8216;Multiple lines of text&#8217;, &#8216;Plain text&#8217; and click ok.</p>
<p>7) Go to the Site Settings -&gt; List templates again and delete the TimerJobSchedule list template you imported on step 3. You need to do  this as preparation for the next step.</p>
<p>8) Now go to the list you created (of type &#8216;TimerJobSchedule&#8217;. Remember, you gave it a name at step 5) and open its settings. Under &#8216;Permissions and Management&#8217; there is a link &#8216;Save list as template&#8217;. Click on it.<br />
<a href="http://hyankov.files.wordpress.com/2009/06/savelistastemplate.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/savelistastemplate.jpg?w=300" border="0" alt="" /></a></p>
<p>9) Under &#8216;file name&#8217; and &#8216;template name&#8217; fields call it &#8216;TimerJobSchedule&#8217; as it used to be when you first imported it. Do not include content and click OK button.</p>
<p>10) Go to site settings again -&gt; List templates. You should see the TimerJobSchedule template there. Click on the Name field of the item, which is a link. Save the file TimerJobSchedule.stp back to <span style="font-weight:bold;">12\TEMPLATE\FEATURES\SharePointerTimerJobScheduler</span>.</p>
<p>You have now effectively added one more column to the list &#8211; LastExceptionMessage.</p>
<p>Now we need to edit the code too. You should have the solution open in your Visual Studio. Open TimerJobScheduler.cs for edit and go to line 140. This is the catch statement, right after the &#8216;<span style="font-weight:bold;">RunTheTimerJobInstance(Item);</span>&#8216; block. As you can see, logging logic is not yet implemented there. What you want to do is add the following code in this catch statement:</p>
<p><span style="font-weight:bold;">Item["LastExceptionMessage"] = NowDateTime + &#8221; &#8211; &#8221; + ex.Message;</span></p>
<p>Basically it will write a time stamped exception message into the &#8216;LastExceptionMessage&#8217; column you have created earlier. As you can see, we don&#8217;t even need logging components such as <a href="http://logging.apache.org/log4net/index.html">log4net</a> at this point. We are using the column to store the message.</p>
<p><span style="font-size:100%;">Right click the &#8216;SharePointerTimerJobScheduler&#8217; project in Visual Studio and select Properties. Go to the Build Events tab and take a look at the &#8220;Post-build event command line&#8221; text box. There is an entry saying:<br />
<span style="color:#000099;">makecab /f solution.ddf</span><span style="font-weight:bold;color:#cc0000;">&#8220;</span></span></p>
<p>Change it to:<br />
<span style="color:#000099;">makecab /f solution.ddf</span></p>
<p>I.e. &#8211; remove the &#8221; character at the end of the line, as it is there by mistake (I guess).</p>
<p>There is also an error in <span style="font-weight:bold;">TimerJobSchedulerFeature.cs</span> file of the source. Find the line:<br />
<span style="color:#000099;">AddListTemplateToGallery(@&#8221;C:\Program Files\Common Files\<br />
Microsoft Shared\web server extensions\12\<br />
TEMPLATE\FEATURES\<span style="color:#cc0000;">TimerJobScheduler</span>\TimerJobSchedule.stp&#8221;);</span></p>
<p>And replace it with:<br />
<span style="color:#000099;">AddListTemplateToGallery(@&#8221;C:\Program Files\Common Files\<br />
Microsoft Shared\web server extensions\12\<br />
TEMPLATE\FEATURES\<span style="color:#990000;">SharePointerTimerJobScheduler</span>\TimerJobSchedule.stp&#8221;);</span></p>
<p>I have notified the developer about those findings <a href="http://sptimerscheduler.codeplex.com/Thread/View.aspx?ThreadId=58771"><span style="font-weight:bold;">here</span></a>.</p>
<p>After you are done with all of the above, rebuild the solution. The &#8220;<span style="font-weight:bold;">Deployment\SharePointerTimerJobScheduler.wsp</span>&#8221; will be refreshed. You need to redeploy it. You can do that by copying &#8216;<span style="font-weight:bold;">SharePointerTimerJobScheduler Source\Deployment\SharePointerTimerJobScheduler.wsp</span>&#8216; (which is the output of the source project) into &#8216;<span style="font-weight:bold;">SharePointerTimerJobScheduler Release 1.1.0.0</span>&#8216; (which was the release folder of the project, if you downloaded it. And you should!).</p>
<p>After deployment, by running &#8216;<span style="font-weight:bold;">SharePointerTimerJobScheduler Release 1.1.0.0\Install Feature.cmd</span>&#8216; (and re-activation of the &#8216;SharePointer Timer Job Scheduler&#8217; site feature) make sure the &#8216;<span style="font-weight:bold;">LastExceptionMessage</span>&#8216; column is visible in your default list view, so you can monitor it for errors.</p>
<p>And that&#8217;s all. Now just make sure that the method you are executing as a timer job, throws a meaningful exception, which will be visualized in the list column!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=27&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/08/sptimerscheduler-for-sharepoint-improvement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/06/listtemplates.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/uploaddocument.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/timerjobschedule.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/savelistastemplate.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>Sending email from SharePoint</title>
		<link>http://hyankov.wordpress.com/2009/06/05/sending-email-from-sharepoint/</link>
		<comments>http://hyankov.wordpress.com/2009/06/05/sending-email-from-sharepoint/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 09:20:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[mailmessage]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[sendemail]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spcontext]]></category>
		<category><![CDATA[sputility]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/05/sending-email-from-sharepoint</guid>
		<description><![CDATA[Did you ever need to send an email out, from your SharePoint custom web application? When you have such a task, perhaps the first idea that you have is to use System.Net.Mail namespace. However, this requires that your application maintains a setting for the SMTP server, reply address and etc. Wouldn&#8217;t it be easier if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=26&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Did you ever need to send an email out, from your SharePoint custom web application? When you have such a task, perhaps the first idea that you have is to use <span style="font-weight:bold;">System.Net.Mail</span> namespace. However, this requires that your application maintains a setting for the SMTP server, reply address and etc. Wouldn&#8217;t it be easier if you could delegate the task of storing this configuration to SharePoint (and its Administrator) and instead, just focus on sending out the actual email?</p>
<p><span class="fullpost"><br />
Your solution is the <span style="font-weight:bold;">Microsoft.SharePoint.Utilities.SPUtility</span> class! It has the very convenient method &#8216;<span style="font-weight:bold;">SendEmail</span>&#8216;. This is basically SharePoint&#8217;s native functionality for email delivery.</span></p>
<p>The first thing you (or the SharePoint Administrator) need to do is setup the Outgoing email SMTP server. Open <span style="font-weight:bold;">Central Admin -&gt; Operations -&gt; </span><span class="ms-sitemapdirectional"><span style="font-weight:bold;">Outgoing E-Mail Settings</span>.</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/outgoingemail.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/outgoingemail.jpg?w=300" border="0" alt="" /></a></p>
<p>There, you need to set the Outbound SMTP server, From address and Reply-to address.<br />
<a href="http://hyankov.files.wordpress.com/2009/06/settings.jpg"><img src="http://hyankov.files.wordpress.com/2009/06/settings.jpg?w=300" border="0" alt="" /></a></p>
<p>And this is exactly how you delegate SMTP setting storage to SharePoint. Now, how do you actually send email from your code?</p>
<p>First, it is always a good idea to check if the email server is set:<br />
<span style="font-weight:bold;">bool isEmailServerSet = SPUtility.IsEmailServerSet(web)</span>;</p>
<p>If this returns false, you should not bother trying to send the email. Instead, show an error message or notify the SharePoint administrator, to check the settings of the server. If it returns true, you are good to go:<br />
<span style="font-weight:bold;">SPWeb web = SPContext.Current.Web;</span><br />
<span style="font-weight:bold;">bool appendHtmlTag = false;</span><br />
<span style="font-weight:bold;">bool htmlEncode = false;</span><br />
<span style="font-weight:bold;">string toAddress = &#8220;test@example.com&#8221;;</span><br />
<span style="font-weight:bold;">string subject = &#8220;Subject&#8221;;</span><br />
<span style="font-weight:bold;">string message = &#8220;Message text&#8221;;</span><br />
<span style="font-weight:bold;">bool result = SPUtility.SendEmail(web, appendHtmlTag, htmlEncode, toAddress, subject, message);</span></p>
<p>In some cases, you may need to run this code with elevated privileges:<br />
<span style="font-weight:bold;">SPSecurity.RunWithElevatedPrivileges(delegate()</span><br />
<span style="font-weight:bold;">{</span><br />
<span style="font-weight:bold;"> bool result = SPUtility.SendEmail(web, appendHtmlTag, htmlEncode, toAddress, subject, message);</span><br />
<span style="font-weight:bold;">});</span></p>
<p>SendEmail method returns a boolean, indicating if sending the email was successful or not.</p>
<p>However, there is a catch in using <span style="font-weight:bold;">SPUtility.SendEmail</span>. Internally this method relies on having a SPContext. In other words &#8211; if you are trying to use <span style="font-weight:bold;">SPUtility.SendEmail</span> from a SharePoint timer, it will fail, because there will be no context. This is when you have no other choice, but use System.Net.Mail. But how can you still benefit from SharePoint storing your SMTP settings? You do it this way:</p>
<p><span style="font-weight:bold;color:#330099;font-size:85%;">SPWeb web = new SPSite(&#8220;<a href="http://example&#038;#8221" rel="nofollow">http://example&#038;#8221</a>;).RootWeb;</span><span style="font-size:85%;"><br />
</span><span style="font-weight:bold;font-size:85%;">string toAddress = &#8220;test@example.com&#8221;;</span><span style="font-size:85%;"><br />
</span><span style="font-weight:bold;font-size:85%;">string subject = &#8220;Subject&#8221;;</span><span style="font-size:85%;"><br />
</span><span style="font-weight:bold;font-size:85%;">string messageText = &#8220;Message text&#8221;;</span><span style="font-size:85%;"><br />
</span><span style="font-weight:bold;font-size:85%;">string replyTo = <span style="color:#330099;">web.Site.WebApplication.OutboundMailReplyToAddress</span>;</span></p>
<p><span style="font-weight:bold;font-size:85%;">MailMessage message = new MailMessage(replyTo, toAddress, subject, messageText);</span><span style="font-size:85%;"><br />
</span><span style="font-weight:bold;font-size:85%;">message.IsBodyHtml = false;</span></p>
<p>string smtpAddress =<br />
<span style="color:#330099;font-size:85%;">web.Site.WebApplication.OutboundMailServiceInstance.Server.Address;</span></p>
<p>SmtpClient smtp = new SmtpClient(smtpAddress);<br />
<span style="font-weight:bold;font-size:85%;">smtp.Send(message);</span></p>
<p>So what did we do here? We use .NET&#8217;s native MailMessage and SmptClient classes, but we still read the configuration from the SharePoint site we opened by URL.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=26&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/05/sending-email-from-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/06/outgoingemail.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/settings.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>Sample SharePoint project localization Part 2 of 2</title>
		<link>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-2-of-2/</link>
		<comments>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-2-of-2/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 14:02:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-2-of-2</guid>
		<description><![CDATA[Hello, This article assumes you are already familiar with Part 1 and the post preceding it. Here, we discuss how to localize the content of the SharePoint custom web site project you already have created. Normally, your ASPX page content would be similar to the following: We want those &#8216;hardcoded&#8217; strings to be localization enabled. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=25&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Hello,</p>
<p>This article assumes you are already familiar with <a href="http://blog.myitechnology.com/2009/06/sample-project-localization-part-1-of-2.html">Part 1</a> and the <a href="http://blog.myitechnology.com/2009/06/localization-of-sharepoint-project.html">post preceding it</a>.</p>
<p>Here, we discuss how to localize the content of the SharePoint custom web site project you already have created.</p>
<p><span class="fullpost"><br />
Normally, your ASPX page content would be similar to the following:<br />
<a href="http://hyankov.files.wordpress.com/2009/06/normalcontent.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/normalcontent.png?w=300" border="0" alt="" /><br />
</a></span></p>
<p>We want those &#8216;hardcoded&#8217; strings to be localization enabled.</p>
<p><span style="font-weight:bold;">1. Create your default resource file.</span><br />
You can create a subfolder &#8216;Resources&#8217; in your project and put it there. Give it a specific name, in our case it is <span style="font-weight:bold;">SampleLocalization.resx</span></p>
<p><span style="font-weight:bold;">2. Extract the strings we want to localize, into a resource file.</span><br />
Let&#8217;s assume we want to have the page title, button text and greeting message localized. We need to create a resource entry for each one of them. Your resource file should look similarly to:<br />
<a href="http://hyankov.files.wordpress.com/2009/06/resourcefile.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/resourcefile.png?w=300" border="0" alt="" /><br />
</a></p>
<p><span style="font-weight:bold;">3. Modify the Page attribute to contain Culture and UICulture tags.</span><br />
It should be similar to:</p>
<p><span style="color:#ff0000;">Inherits=&#8221;SampleCode.Localized, SampleCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=[Public Key Token]&#8221; </span><span style="font-weight:bold;color:#ff0000;">Culture=&#8221;auto&#8221; UICulture=&#8221;auto&#8221;</span><span style="color:#ff0000;"> %&gt;</span></p>
<p><span style="font-weight:bold;">4. Modify your page to refer to the resources, rather than the hardcoded strings</span><br />
<a href="http://hyankov.files.wordpress.com/2009/06/localizedcontent.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/localizedcontent.png?w=300" border="0" alt="" /><br />
</a></p>
<p><span style="font-weight:bold;">5. Make a copy of your resource file. This will be our second language. Let&#8217;s make it Bulgarian.</span><br />
Name it &#8216;SampleLocalization.bg.resx&#8217;. Open it for editing and translate the text. For your convenience, here are the strings:</p>
<p>Button_Text &#8211; Бутон текст<br />
Greeting &#8211; Здравейте, това е тест<br />
Page_Title &#8211; Това е заглавието на страницата</p>
<p>Make sure you store it in the Resources folder, next to your SampleLocalization.resx file.</p>
<p><span style="font-weight:bold;">6. web.config modification</span><br />
Open the web.config of the website that hosts your template page. Find (or add) your <span style="font-weight:bold;">globalization </span>node and modify it to contain Culture and UICulture attributes, equaling &#8216;auto&#8217;.<br />
<a href="http://hyankov.files.wordpress.com/2009/06/globalization.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/globalization.png?w=300" border="0" alt="" /><br />
</a></p>
<p><span style="font-weight:bold;">7. Deployment</span><br />
Do a full deploy of your project. Also, don&#8217;t forget to copy your *.resx files (both of them) into the WSS VirtualDirectories App_GlobalResources. The path usually is:<br />
<span style="font-weight:bold;"><br />
C:\Inetpub\wwwroot\wss\VirtualDirectories\<span style="font-style:italic;">[Port Number]</span>\App_GlobalResources<br />
</span></p>
<p>Open the web page in the browser and see the result. You can set language preference through the settings of your browser.<br />
<span class="fullpost"><br />
For IE:<br />
Tools -&gt; Internet Options -&gt; General Tab -&gt; Languages -&gt; Add / Move Up / Move Down</span></p>
<p>For FF:<br />
Tools -&gt; Options -&gt; Content tab -&gt; Languages (bottom) Choose button -&gt; Add / Move Up / Move Down</p>
<p>Add Bulgarian. Try how it works when Bulgarian is a first preference, or when it is last.</p>
<p>In English:<br />
<a href="http://hyankov.files.wordpress.com/2009/06/inenglish.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/inenglish.png?w=300" border="0" alt="" /><br />
</a></p>
<p>In Bulgarian:<br />
<a href="http://hyankov.files.wordpress.com/2009/06/inbulgarian.png"><br />
<img src="http://hyankov.files.wordpress.com/2009/06/inbulgarian.png?w=300" border="0" alt="" /><br />
</a></p>
<p>Hope this is helpful,<br />
Hristo Yankov</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=25&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-2-of-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/06/normalcontent.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/resourcefile.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/localizedcontent.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/globalization.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/inenglish.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/inbulgarian.png?w=300" medium="image" />
	</item>
		<item>
		<title>Sample SharePoint project localization Part 1 of 2</title>
		<link>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-1-of-2/</link>
		<comments>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-1-of-2/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 13:18:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[application]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[step by step]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-1-of-2</guid>
		<description><![CDATA[Hello, This is a step-by-step tutorial on how to create a localized SharePoint custom web application. In this first part, we will discuss the creation of the sample web application itself, while the second one, will emphasize on the localization. Prerequisite is a Visual Studio 2008 with WSS extensions 1.3. You can also work with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=24&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Hello,</p>
<p>This is a step-by-step tutorial on how to create a localized SharePoint custom web application. In this first part, we will discuss the creation of the sample web application itself, while the second one, will emphasize on the localization.</p>
<p>Prerequisite is a Visual Studio 2008 with WSS extensions 1.3. You can also work with Visual Studio 2005, but you will have to do part of the deployment manually.</p>
<p><span class="fullpost"> </span></p>
<p><span style="font-weight:bold;">1. Start Visual Studio and create new project of type SharePoint.</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/newproject.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/newproject.png"><img src="http://hyankov.files.wordpress.com/2009/06/newproject.png?w=300" border="0" alt="" /></a></p>
<p>I entered &#8216;SPLocalization&#8217; as name for the project.</p>
<p><span style="font-weight:bold;">2. Select &#8220;Full Trust&#8221;</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/fulltrust.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/fulltrust.png"><img src="http://hyankov.files.wordpress.com/2009/06/fulltrust.png?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">Note:</span> Check debug tab of Project Setting to ensure it contain correct path to your SharePoint server.</p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/debugoptions.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/debugoptions.png"><img src="http://hyankov.files.wordpress.com/2009/06/debugoptions.png?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">3. Add new item to our project</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/addnewitem.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/addnewitem.png"><img src="http://hyankov.files.wordpress.com/2009/06/addnewitem.png?w=300" border="0" alt="" /></a></p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;font-weight:bold;"><span style="font-size:85%;">4.  Select &#8216;Template&#8217; element in SharePoint section. Change file name to &#8216;LocalizedPage.aspx&#8217;</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/template.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/template.png"><img src="http://hyankov.files.wordpress.com/2009/06/template.png?w=300" border="0" alt="" /></a></p>
<p>&#8211;   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  &#8211;&gt;</p>
<p style="margin-bottom:0;font-weight:bold;"><span style="font-size:85%;">5. Now you should see project structure like this:</span></p>
<p style="margin-bottom:0;font-weight:bold;"><a href="http://hyankov.files.wordpress.com/2009/06/projectstructure.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/projectstructure.png"><img src="http://hyankov.files.wordpress.com/2009/06/projectstructure.png?w=253" border="0" alt="" /></a></p>
<p style="margin-bottom:0;font-weight:bold;">
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;font-weight:bold;"><span style="font-size:85%;">6. Create subfolder LAYOUTS under Template folder</span></p>
<p style="margin-bottom:0;font-weight:bold;"><span style="font-size:85%;">7. Create subfolder SPLocalization under LAYOURS folder</span></p>
<p style="margin-bottom:0;font-weight:bold;"><span style="font-size:85%;">8. Move LocalizedPage.aspx to SPLocalization folder (I use drag and drop the file). Now you should have the following structure:</span></p>
<p style="margin-bottom:0;"><a href="http://hyankov.files.wordpress.com/2009/06/newstructure.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/newstructure.png"><img src="http://hyankov.files.wordpress.com/2009/06/newstructure.png?w=257" border="0" alt="" /></a></p>
<p style="margin-bottom:0;"><span style="font-weight:bold;">9. Now let&#8217;s create a class that extends SharePoint layout pages. Add new class to your project.</span></p>
<p style="margin-bottom:0;"><a href="http://hyankov.files.wordpress.com/2009/06/newclass.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/newclass.png"><img src="http://hyankov.files.wordpress.com/2009/06/newclass.png?w=272" border="0" alt="" /></a></p>
<p style="margin-bottom:0;">
<p><span style="font-weight:bold;">10. Name it &#8216;LocalizedPage.aspx.cs&#8217; and click &#8220;Add&#8221; button</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/addclass.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/addclass.png"><img src="http://hyankov.files.wordpress.com/2009/06/addclass.png?w=300" border="0" alt="" /></a></p>
<p>&lt;!&#8211;   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in <span style="font-weight:bold;">11. Now few other steps &#8230;</span></p>
<p>First add references to SharePoint and SharePoint.WebControls<span style="font-weight:bold;"> </span></p>
<p><span style="color:#330099;">using </span>Microsoft.SharePoint;</p>
<p><span style="color:#330099;">using </span>Microsoft.SharePoint.WebControls;<span style="font-weight:bold;"> </span></p>
<p>Secondly make your class <span style="color:#330099;">public</span>, <span style="color:#330099;">partial </span>and derived from <span style="color:#336666;">LayoutsPageBase</span><span style="font-weight:bold;"> </span></p>
<p>You should see something like this:<span style="font-weight:bold;"> </span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/code.png"><img src="http://hyankov.files.wordpress.com/2009/06/code.png?w=300" border="0" alt="" /></a></p>
<p>Now, since we have chosen GAC deployment model, we need to deploy our solution to Global Assembly and determine Public Key.</p>
<p><span style="font-weight:bold;">12. In Visual Studio Menu, Selection, Build -&gt; Quick Deploy Solution -&gt; Copy Binary(s)</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/copybinaries.png"><img src="http://hyankov.files.wordpress.com/2009/06/copybinaries.png?w=300" border="0" alt="" /></a></p>
<p>This will compile our SharePoint project into DLL and deploy it to GAC. After deployment Output window will show that Deployment was successful:</p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/output.png"><img src="http://hyankov.files.wordpress.com/2009/06/output.png?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">13. Let&#8217;s go to Windows Assembly folder and find our library</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/gac.png"><img src="http://hyankov.files.wordpress.com/2009/06/gac.png?w=300" border="0" alt="" /></a></p>
<p>If you open Properties of our assembly, you will be able to copy its public key token. In my case it was <span style="font-weight:bold;">7a1fde53a908a4fe</span>.</p>
<p>We will need Public Key Token for our aspx.page.</p>
<p>Now, let&#8217;s return to our ASPX page.</p>
<p><span style="font-weight:bold;">14. Remove default text and add Page registration tag</span></p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;"><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;%<span style="font-size:85%;">@Page Language=&#8221;C#&#8221; MasterPageFile=&#8221;~/_layouts/application.master&#8221; Inherits=&#8221;{ClassName}, {Assembly}, Version=1.0.0.0, Culture=neutral, PublicKeyToken={PublicKeyToken}&#8221; %&gt;</span></p>
<p style="margin-bottom:0;">Now let&#8217;s replace {ClassName} with SPLocalization.LocalizedPage {Assembly} with SPLocalization {PublicKeyToken} with Public Key Token we obtained from GAC.</p>
<p style="margin-bottom:0;">Now you should see something like this:</p>
<p style="margin-bottom:0;"><a href="http://hyankov.files.wordpress.com/2009/06/localizedpageaspx.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/localizedpageaspx.png"><img src="http://hyankov.files.wordpress.com/2009/06/localizedpageaspx.png?w=300" border="0" alt="" /></a></p>
<p style="margin-bottom:0;">Now let&#8217;s add some content to the page and test if everything works.</p>
<p><span style="font-weight:bold;"> </span></p>
<p>15. Add ASP tag Content with ContentPlaceHolderID equals to PlaceHolderMain. Here is complete code</p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;<span style="font-size:85%;">asp:Content ID=&#8221;Main&#8221; ContentPlaceHolderID=&#8221;PlaceHolderMain&#8221; runat=&#8221;server&#8221;&gt;</span></p>
<p style="margin-bottom:0;"><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">Test message</span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;!&#8211;<span style="font-size:85%;">asp:Content&gt;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p>Your Localized.aspx page should look like this:</p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;%<span style="font-size:85%;">@Page Language=&#8221;C#&#8221; MasterPageFile=&#8221;~/_layouts/application.master&#8221; Inherits=&#8221;SPLocalization.LocalizedPage, SPLocalization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7a1fde53a908a4fe&#8221;%&gt;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;<span style="font-size:85%;">asp:Content ID=&#8221;Main&#8221; ContentPlaceHolderID=&#8221;PlaceHolderMain&#8221; runat=&#8221;server&#8221;&gt;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">Test message</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;!&#8211;<span style="font-size:85%;">asp:Content&gt;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-weight:bold;color:#000000;">16. Let&#8217;s make a full deploy. Visual Studio menu Build -&gt; Deploy Solution.</span></p>
<p><span style="color:#000000;">After deployment is completed, Output window will show that Deploy was successful.</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/deployed.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/deployed.png"><img src="http://hyankov.files.wordpress.com/2009/06/deployed.png?w=300" border="0" alt="" /></a></p>
<p><span style="font-weight:bold;">17. Now let&#8217;s go and check manually if LocalizedPage.aspx was deployed. </span></p>
<p>Browse to 12 directory (by default it is &#8220;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12&#8243;) then browse to TEMPLATE, then to LAYOUTS, then to SPLocalization. You should see our LozalizedPage.aspx was successfully deployed.</p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/deployedfolder.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/deployedfolder.png"><img src="http://hyankov.files.wordpress.com/2009/06/deployedfolder.png?w=300" border="0" alt="" /></a></p>
<p>Now let&#8217;s try to access this page through SharePoint</p>
<p><span style="font-weight:bold;">18. Open SharePoint url of your site with prefix &#8220;_layouts/SPLocalization/LocalizedPage.aspx&#8221;.</span></p>
<p>In my case, it is &#8220;<a href="http://itech-vm-spdev/_layouts/SPLocalization/LocalizedPage.aspx&#038;#8221" rel="nofollow">http://itech-vm-spdev/_layouts/SPLocalization/LocalizedPage.aspx&#038;#8221</a>;</p>
<p>When page is loaded you should see empty area but with our magic text: Test message</p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/testmessage.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/testmessage.png"><img src="http://hyankov.files.wordpress.com/2009/06/testmessage.png?w=300" border="0" alt="" /></a></p>
<p>Now, let&#8217;s add SPLinkButton SharePoint control</p>
<p><span style="font-weight:bold;">19. Change your ASPX page to include Register of Microsoft.SharePoint assembly and replace static text with SPLinkButton control.</span></p>
<p>Your ASPX page should look like this:</p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;"><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;%<span style="font-size:85%;">@Page Language=&#8221;C#&#8221; MasterPageFile=&#8221;~/_layouts/application.master&#8221; Inherits=&#8221;SPLocalization.LocalizedPage, SPLocalization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7a1fde53a908a4fe&#8221;%&gt;</span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;%<span style="font-size:85%;">@Register Assembly=&#8221;Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&#8221; Namespace=&#8221;Microsoft.SharePoint.WebControls&#8221; TagPrefix=&#8221;cc1&#8243; %&gt;</span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;<span style="font-size:85%;">asp:Content ID=&#8221;Main&#8221; ContentPlaceHolderID=&#8221;PlaceHolderMain&#8221; runat=&#8221;server&#8221;&gt;</span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;<span style="font-size:85%;">cc1:SPLinkButton Text=&#8221;" runat=&#8221;server&#8221; ID=&#8221;myLink&#8221; /&gt;</span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;"> </span></p>
<p>&lt;!&#8211;<span style="font-size:85%;">asp:Content&gt;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-weight:bold;color:#000000;">20. Update your LocalizedPage class to include myLink definition. We will also assign Text value in OnLoad method. You class should look like this:</span></p>
<p><!--   @page { size: 8.5in 11in; margin: 0.79in }   P { margin-bottom: 0.08in }  --></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">public partial class LocalizedPage : LayoutsPageBase</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">{</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">protected SPLinkButton myLink;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">protected override void OnLoad(EventArgs e)</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">{</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">myLink.Text =&#8221;Our test link&#8221;;</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">}</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p style="margin-bottom:0;"><span style="color:#0000ff;"> </span></p>
<p><span style="font-family:Courier New,monospace;"> </span></p>
<p><span style="font-size:85%;">}</span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="font-weight:bold;color:#000000;">21. Let&#8217;s do full deploy again</span></p>
<p><span style="font-weight:bold;"> </span></p>
<p><span style="color:#000000;">22. Once it is successfully deployed. Open LocalizedPage in the browser again. You should see that now you have a link on the page. This link is provided by SharePoint SPLinkButton control.</span></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/ourtestlink.png"></a></p>
<p><a href="http://hyankov.files.wordpress.com/2009/06/ourtestlink.png"><img src="http://hyankov.files.wordpress.com/2009/06/ourtestlink.png?w=201" border="0" alt="" /></a></p>
<p>In the next article, we will discuss localization of the sample application we created&#8230;</p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<p><span style="color:#0000ff;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=24&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/02/sample-sharepoint-project-localization-part-1-of-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2009/06/newproject.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/fulltrust.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/debugoptions.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/addnewitem.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/template.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/projectstructure.png?w=253" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/newstructure.png?w=257" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/newclass.png?w=272" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/addclass.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/code.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/copybinaries.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/output.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/gac.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/localizedpageaspx.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/deployed.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/deployedfolder.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/testmessage.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2009/06/ourtestlink.png?w=201" medium="image" />
	</item>
		<item>
		<title>Localization of SharePoint Project</title>
		<link>http://hyankov.wordpress.com/2009/06/02/localization-of-sharepoint-project/</link>
		<comments>http://hyankov.wordpress.com/2009/06/02/localization-of-sharepoint-project/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:02:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[resource files]]></category>
		<category><![CDATA[resx]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2009/06/02/localization-of-sharepoint-project</guid>
		<description><![CDATA[By Hristo Yankov UPDATE: For detailed step by step tutorial, check those posts: SharePoint localization step-by-step part 1 SharePoint localization step-by-step part 2 Problem: The users require that your custom SharePoint ASP.NET site is available in more than one language. For instance &#8211; English and Hungarian. Solution: ASP.NET localization. Technique is discussed in this article, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=22&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="font-style:italic;">By Hristo Yankov</span></p>
<p><span style="font-weight:bold;color:rgb(255,0,0);">UPDATE: </span>For detailed step by step tutorial, check those posts:<br />
<br /><a href="http://blog.myitechnology.com/2009/06/sample-project-localization-part-1-of-2.html">SharePoint localization step-by-step part 1</a><br />
<br /><a href="http://blog.myitechnology.com/2009/06/sample-sharepoint-project-localization.html">SharePoint localization step-by-step part 2</a></p>
<p><span style="font-weight:bold;">Problem</span>: The users require that your custom SharePoint ASP.NET site is available in more than one language. For instance &#8211; English and Hungarian.</p>
<p><span style="font-weight:bold;">Solution</span>: ASP.NET localization. Technique is discussed in this article, step by step.</p>
<p>It is recommended that you leave localization to the end of the development, when page content is not going to change (too often). Otherwise, you will find yourself constantly syncing new web content with the resource files.</p>
<p><span class="fullpost"><br />
<br /><span style="font-weight:bold;">1. Create resource files.</span><br />
<br />Create a folder in your project called, for example, &#8216;Resources&#8217; and add a new .resx file (right click -&gt; Add -&gt; New Item -&gt; General -&gt; Resource file) in it. DON&#8217;T give it a generic name like &#8216;Resources.resx&#8217;. Instead, name it similarly to your project &#8211; e.g. <span style="font-weight:bold;">WarehouseManagement.resx</span>. This will be the resource file for your default language (let&#8217;s assume it&#8217;s English).</p>
<p><span style="font-weight:bold;">2. Extract site content in the resource file</span><br />
<br />This is a boring, but relatively easy task to do. You need to extract page contents such as literals, control texts, headers, titles and etc. into the resource file. The actual text is being replaced with Resource reference, using:<br />

<pre><span style="color:rgb(0,0,102);">&lt;%$ Resources:[Resource File Name Without Extension],
<br />[Resource Name]%&gt;</span>
<br /></pre>
<p>For example, if you have:<br />

<pre><span style="color:rgb(0,0,102);">&lt;cc1:sptoolbarbutton id="btnSearch" runat="server" text="<span style="font-weight:bold;">Search</span>" </span>
<br /><span style="color:rgb(0,0,102);">OnClick="btnSearch_Click"/&gt;</span></pre>
<p>You extract the &#8216;Search&#8217; button text into the resource file, and let&#8217;s assume you give it a key &#8216;<span style="font-weight:bold;">btn_Search</span>&#8216;. Then you edit the button code so that you end up with:<br />

<pre><span style="color:rgb(0,0,102);">&lt;cc1:sptoolbarbutton id="btnSearchProperty" runat="server"
<br />text="<span style="font-weight:bold;">&lt;%$Resources:WarehouseManagement,btn_Search %&gt;</span>"
<br />OnClick="btnSearch_Click"/&gt;</span>
<br /></pre>
<p>Another example:<br />

<pre><span style="color:rgb(0,0,102);">&lt;asp:content id="PageTitle" contentplaceholderid="PlaceHolderPageTitle" runat="server"&gt;</span><span style="font-weight:bold;color:rgb(0,0,102);">
<br />My Title Goes Here</span><span style="color:rgb(0,0,102);">
<br />&lt;/asp:content&gt;</span>
<br /></pre>
<p>You extract &#8216;My Title Goes Here&#8217; into the Resource file and let&#8217;s say you give it a key &#8216;Page_Title&#8217;. Then, you replace the page content with:<br />

<pre><span style="color:rgb(0,0,102);">&lt;asp:content id="PageTitle"
<br />contentplaceholderid="PlaceHolderPageTitle"
<br />runat="server"&gt;</span><span style="font-weight:bold;color:rgb(0,0,102);">
<br /></span><span style="color:rgb(0,0,102);font-weight:bold;">&lt;asp:Literal ID="literal" runat="server"
<br />Text="&lt;%$ Resources:WarehouseManagement,Page_Title %&gt;" /&gt;</span>
<br /><span style="color:rgb(0,0,102);">&lt;/asp:content&gt;</span>
<br /></pre>
<p>Note that you can&#8217;t just have &#8216;<span style="font-weight:bold;"></span>&#8216; standing alone. This code either has to be embedded into another control&#8217;s property (Text, HeaderText, ErrorMessage, etc) or it has to be in a placeholder, which in this case is asp:Literal.</p>
<p>You need to do this for every text you want to localize.</p>
<p>Also, every page you are localizing, has to have those two attributes in the &#8216;Page&#8217; node: Culture=&#8221;auto&#8221; UICulture=&#8221;auto&#8221;. Example:<br />
<br /><span style="color:rgb(0,0,102);">&lt;%@ Page Language=&quot;c#&quot; MasterPageFile=&quot;~/_layouts/WarehouseManagement.master&quot; Inherits=&quot;TestPage, WarehouseManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=[token]&quot; </span><span style="font-weight:bold;color:rgb(0,0,102);">Culture=&#8221;auto&#8221; UICulture=&#8221;auto&#8221;</span><span style="color:rgb(0,0,102);"> %&gt;</span></p>
<p><span style="font-weight:bold;">3. Second language</span><br />
<br />Once you are done moving your text into the resource file, you can make a copy of your resource file. Since we are localizing to Hungarian, rename the copy of the file to WarehouseManagement.<span style="font-weight:bold;">hu.resx</span>. Open the resource file for editing and translate the entries from English to Hungarian.</p>
<p>You have to keep the two resource files in sync. If you delete keys, add new ones or rename in one of them, the other one has to reflect it too.</p>
<p><span style="font-weight:bold;">4. web.config change</span><br />
<br />Make sure you have this node in your site&#8217;s web.config file:<br />

<pre>&lt;globalization fileencoding="utf-8"
<br />uiCulture="auto" culture="auto" /&gt;</pre>
<p><span style="font-weight:bold;">5. Deployment</span><br />
<br />Those resource files need to be deployed to your site&#8217;s App_GlobalResources folder. This usually is: C:\Inetpub\wwwroot\wss\VirtualDirectories\[Port Number]\App_GlobalResources</p>
<p><span style="font-weight:bold;">6. Language Preference</span><br />
<br />So how exactly do you set the language preference? How do you tell the page which localization (English or Hungarian) you want to see? That&#8217;s easy. Go to your browser&#8217;s Language setting and set your preference.</p>
<p>For IE:<br />
<br />Tools -&gt; Internet Options -&gt; General Tab -&gt; Languages -&gt; Add / Move Up / Move Down</p>
<p>For FF:<br />
<br />Tools -&gt; Options -&gt; Content tab -&gt; Languages (bottom) Choose button -&gt; Add / Move Up / Move Down</p>
<p>Your browser provides the page what is your language preference, by sending an appropriate header. So, at this point, what happens when the page renders? Browser sends the page request, along with the language preference header. ASP.NET replaces the resource reference with the actual value, from the <span style="font-weight:bold;">appropriate</span> resource file.</p>
<p>How ASP.NET determines which one is the appropriate resource file? Easy. Let&#8217;s say your first language preference is Arabic, second is Hungarian and third is English. You open the page, ASP.NET tries to find arabic localization file but fails, then it tries to locate Hungarian localization file &#8211; it is found and it is determined as the appropriate one to use.</p>
<p>What happens if your only language preference is &#8216;Arabic&#8217; (and in our case, we don&#8217;t have localization for it)? We send the request, ASP.NET doesn&#8217;t find the right localization and since you don&#8217;t have other language preferences, it falls back to the default resource file, which is WarehouseManagement.resx and happens to be in English.</p>
<p>This gives you the ability to &#8216;plug and play&#8217; new language localizations by simply copying one of the existing .resx files, give it a proper extension (depending on the language you are localizing to), translate the content and deploy it to the right location. You won&#8217;t need to change anything on your pages.</p>
<p>Also, note that this architecture allows every client of the web application to set language preference for himself, rather than you, setting the language translation globally for the whole site and every user.</p>
<p>For automation of the deployment of resource files, you may want to look into this blog post:<br />

<p><a href="http://www.mikhaildikov.com/2007/03/sharepoint-resources-types-use-and_2163.html">SharePoint Resources, Types, Use and Deployment</a></p>
<p></span><span class="fullpost"><br />
<br /></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=22&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2009/06/02/localization-of-sharepoint-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>
	</item>
		<item>
		<title>K2 [blackpoint] Installation Wrong Type of Database</title>
		<link>http://hyankov.wordpress.com/2008/10/08/k2-blackpoint-installation-wrong-type-of-database/</link>
		<comments>http://hyankov.wordpress.com/2008/10/08/k2-blackpoint-installation-wrong-type-of-database/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 00:53:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[blackpearl]]></category>
		<category><![CDATA[blackpoint]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[uninstall]]></category>
		<category><![CDATA[wrong type]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2008/10/08/k2-blackpoint-installation-wrong-type-of-database</guid>
		<description><![CDATA[By Hristo YankovAs of today, you can install K2 [blackpoint] only on a clean (K2-free) environment. So if you are trying to install K2 [blackpoint] on an environment previously or currently used by K2 [blackpearl], you have no choice but uninstall K2 [blackpearl]. What you should be aware of, however, is the fact that the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=16&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="font-style:italic;">By Hristo Yankov</span><a href="http://www.scth.com/images/sc_k2_logo.jpg"><img src="http://www.scth.com/images/sc_k2_logo.jpg" alt="" border="0" /></a><br />As of today, you can install K2 [blackpoint] only on a clean (K2-free) environment. So if you are trying to install K2 [blackpoint] on an environment previously or currently used by K2 [blackpearl], you have no choice but uninstall K2 [blackpearl].</p>
<p>What you should be aware of, however, is the fact that the K2 [blackpearl] uninstaller <span style="font-weight:bold;">does not</span> remove the K2 databases (HostServer, Categories, Dependencies, etc) from the SQL server! <span class="fullpost">If you try to install the K2 [blackpoint] databases on the same SQL server and haven&#8217;t deleted the K2 [blackpearl] databases manually, you will end up with the following errors during the K2 [blackpoint] installation:</p>
<p><a href="http://xs230.xs.to/xs230/08355/blackpointerror601.jpg"><img src="http://xs230.xs.to/xs230/08355/blackpointerror601.jpg" alt="" border="0" /></a><br /><a href="http://xs230.xs.to/xs230/08355/blackpointerror2376.jpg"><img src="http://xs230.xs.to/xs230/08355/blackpointerror2376.jpg" alt="" border="0" /></a></p>
<p>So long story made short, make sure the K2 [blackpoint] database installation does not overlap with existing K2 [blackpearl] databases, as they are not being removed by uninstaller.<br /></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=16&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2008/10/08/k2-blackpoint-installation-wrong-type-of-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://www.scth.com/images/sc_k2_logo.jpg" medium="image" />

		<media:content url="http://xs230.xs.to/xs230/08355/blackpointerror601.jpg" medium="image" />

		<media:content url="http://xs230.xs.to/xs230/08355/blackpointerror2376.jpg" medium="image" />
	</item>
		<item>
		<title>K2 Workspace 404 Not Found Error</title>
		<link>http://hyankov.wordpress.com/2008/10/08/k2-workspace-404-not-found-error/</link>
		<comments>http://hyankov.wordpress.com/2008/10/08/k2-workspace-404-not-found-error/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 00:05:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[404]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[blackpearl]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[not found]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[workspace]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2008/10/08/k2-workspace-404-not-found-error</guid>
		<description><![CDATA[By Hristo Yankov In the process of a K2 installation, no matter distributed or on a single server, you have to setup the K2 Workspace. It is mostly well covered by the K2 Getting Started (Installation) documentation. However, even if you follow strictly the instructions, you might get a 404 (Not Found) error when trying [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=15&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.avgjoeblogger.com/wp-content/uploads/2007/09/404.png"><img src="http://www.avgjoeblogger.com/wp-content/uploads/2007/09/404.png" alt="" border="0" /></a><span style="font-style:italic;">By Hristo Yankov</span></p>
<p>In the process of a K2 installation, no matter distributed or on a single server, you have to setup the K2 Workspace. It is mostly well covered by the K2 Getting Started (Installation) documentation.</p>
<p>However, even if you follow strictly the instructions, you might get a <span style="font-weight:bold;">404 (Not Found)</span> error when trying to access your Workspace. The following is a step by step guide on how to troubleshoot this error.</p>
<p><span class="fullpost"><br />So you open your K2 Workspace and you are greeted by a 404 (Not Found) error. First thing you need to do is enable the logging of your K2 workspace web site. You can do that by running IIS Manager, navigating to Web sites, locating your K2 website, right clicking on it, selecting Properties from the context menu. It will open the properties of your web site. Navigate to the Web Site tab. There is a checkbox called &#8216;<span style="font-weight:bold;">Enable Logging</span>&#8216;. Check it, and just in case do &#8216;iisreset&#8217;. Make a note of where the log is stored. It is usually in a <span style="font-weight:bold;">C:\WINDOWS\system32\LogFiles\</span> folder.</p>
<p>Open your K2 Workspace site again, so the error is logged. Then navigate to the log folder and open the log file. You should see entries similar to:<br /><span style="font-weight:bold;">YYYY-MM-DD HH:MM:SS W3SVCXXXX XX.XX.XX.XX GET /Workspace/default.aspx &#8211; 80 Domain\User XX.XX.XX.X long-client-description-entry-here <span style="color:rgb(204,0,0);">404 2 1260</span></span></p>
<p>The most important part of this error log is the error code. It is &#8220;404 2 1260&#8243;. 404, not found, could be caused by a couple of reasons. It is the &#8220;2&#8243; and &#8220;1260&#8243; part of this entry that specify what exactly it is. If you refer to <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0f4ac79a-dc2b-4a5f-89c1-d57266aa6ffe.mspx?mfr=true">this URL</a> you will see that &#8217;2&#8242; stands for &#8220;<span style="font-weight:bold;">Web service extension lockdown policy prevents this request.</span>&#8221; Basically, you have a policy, which is preventing the server from hosting the file.</p>
<p>Now, how to fix that? Go back to the IIS Manager and right click on the &#8220;Web Service Extensions&#8221; folder. From the context menu select &#8220;Allow all Web service extensions for specific application&#8230;&#8221;.<br /><a href="http://hyankov.files.wordpress.com/2008/10/iis.jpg"><img src="http://hyankov.files.wordpress.com/2008/10/iis.jpg?w=300" alt="" border="0" /></a></p>
<p>Then from the pop up window select ASP.NET v2.0 and click ok. iisreset and you should be fine.<br /><a href="http://hyankov.files.wordpress.com/2008/10/aspnet.jpg"><img src="http://hyankov.files.wordpress.com/2008/10/aspnet.jpg?w=300" alt="" border="0" /></a></p>
<p>If your error is not 404 x 2, but something else, the URL above should give you a hint on the root cause.</p>
<p>In the case of 404 x 2, this will fix your problem, but you might want to experiment with the Web Service Extensions policies, in order to achieve higher security level.<br /></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=15&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2008/10/08/k2-workspace-404-not-found-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://www.avgjoeblogger.com/wp-content/uploads/2007/09/404.png" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/10/iis.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/10/aspnet.jpg?w=300" medium="image" />
	</item>
		<item>
		<title>Troubleshooting Kerberos issues</title>
		<link>http://hyankov.wordpress.com/2008/09/26/troubleshooting-kerberos-issues/</link>
		<comments>http://hyankov.wordpress.com/2008/09/26/troubleshooting-kerberos-issues/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 16:02:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[blackpearl]]></category>
		<category><![CDATA[hell]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[kerberos]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[service principal name]]></category>
		<category><![CDATA[spn]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2008/09/26/troubleshooting-kerberos-issues</guid>
		<description><![CDATA[By Hristo Yankov Dealing with Kerberos in MOSS/K2 distributed environment is inevitable. First, let&#8217;s start with a quick overview of what is Kerberos. From Wiki: Kerberos is a computer network authentication protocol, which allows individuals communicating over a non-secure network to prove their identity to one another in a secure manner. It is also a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=13&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="font-style:italic;">By Hristo Yankov</span></p>
<p><a href="http://hyankov.files.wordpress.com/2008/09/cerberus.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/cerberus.jpg?w=288" alt="" border="0" /></a>Dealing with Kerberos in MOSS/K2 distributed environment is inevitable. First, let&#8217;s start with a quick overview of what is Kerberos.</p>
<p><a href="http://en.wikipedia.org/wiki/Kerberos_%28protocol%29">From Wiki:</a><br /><b></b><br />
<blockquote><b>Kerberos</b> is a <a href="http://en.wikipedia.org/wiki/Computer_network" title="Computer network">computer network</a> <a href="http://en.wikipedia.org/wiki/Authentication" title="Authentication">authentication</a> <a href="http://en.wikipedia.org/wiki/Cryptographic_protocol" title="Cryptographic protocol">protocol</a>, which allows individuals communicating over a non-secure network to prove their identity to one another in a secure manner. It is also a suite of <a href="http://en.wikipedia.org/wiki/Free_software" title="Free software">free software</a> published by <a href="http://en.wikipedia.org/wiki/Massachusetts_Institute_of_Technology" title="Massachusetts Institute of Technology">Massachusetts Institute of Technology</a> (MIT) that implements this protocol. Its designers aimed primarily at a <a href="http://en.wikipedia.org/wiki/Client-server" title="Client-server">client-server</a> model, and it provides mutual authentication — both the user and the server verify each other&#8217;s identity. Kerberos protocol messages are protected against <a href="http://en.wikipedia.org/wiki/Eavesdropping" title="Eavesdropping">eavesdropping</a> and <a href="http://en.wikipedia.org/wiki/Replay_attack" title="Replay attack">replay attacks</a>.</p>
</blockquote>
<p><span class="fullpost"><br />What this means in the MOSS (with K2 worklist web part)/K2 context is:<br />End client&#8217;s browser requests MOSS page featuring the K2 web part, MOSS delegates the client&#8217;s credential to K2, K2 knows who the end user is and retrieves his or her worklist items.</p>
<p>Since this is a &#8216;troubleshooting Kerberos&#8217; article and not &#8216;setting up Kerberos for first time&#8217; we will assume that:
<ul>
<li>You have supposedly configured your network to work with it, by following the K2 documentation (Getting Started)</li>
<li>You went to the Active Directory on the Domain Controller and gave the computers and users participating in the process a Delegate right.</li>
<li><a href="http://support.microsoft.com/kb/215383">You have configured IIS to use Negotiate, rather than NTLM<br /></a></li>
<li>You DO have worklist items waiting for you.</li>
<li>If you have more than one domain controller in the network you realize that replication time could be a problem. Make sure that if you do some domain changes (adding/removing SPN, trusting delegation and etc) you either <a href="http://technet.microsoft.com/en-us/library/cc776188.aspx">force</a> the replication or wait for the period of time. You might want to decrease it to 10-15 minutes.</li>
</ul>
<p>Now, if you don&#8217;t see any of your items in the MOSS K2 web part, that&#8217;s the first sign your Kerberos setup is not working. Login to your K2 server (using the K2 Service credentials!), go to the Services and stop the BlackPearl service. Then run it in console mode so you can clearly see what the error is. Chances are, you will see error messages telling you that the user &#8216;<b>NT AUTHORITY\ANONYMOUS LOGON&#8217; <span style="font-weight:bold;"></span></b><span style="font-style:italic;"></span> was denied access.<br /><a href="http://hyankov.files.wordpress.com/2008/09/blackpearlserver.png"><img src="http://hyankov.files.wordpress.com/2008/09/blackpearlserver.png?w=300" alt="" border="0" /></a></p>
<p>Obviously what happens is &#8211; IIS is not passing the end client credentials to the next server in the chain, which in our particular case is the K2 server. Now starts the fun part, trying to determine why your Kerberos configuration is not working. Logically, you would start by enabling the Kerberos logging on all participating machines. You do that by running regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters. You should add a REG_DWORD entry with value of &#8217;1&#8242;. Also, on the machine issuing TGT you should add the key <span id="ctl00_ContentPlaceHolder1_MicrosoftKBArticle">KerbDebugLevel with value of &#8217;1&#8242;, in the same Parameters folder.</span> Enabling Kerberos logging is also explained <a href="http://support.microsoft.com/kb/262177">here</a>.</p>
<p>You might notice that Kerberos delays error logging, skips some or just doesn&#8217;t output when you expect it to. Eventually you will start seeing some logs in you Event Log viewer, System section. There might be gems such as:
<ul>
<li>KDC_ERR_S_PRINCIPAL_UNKNOWN</li>
<li>KDC_ERR_BADOPTION</li>
<li>KRB_ERR_RESPONSE_TOO_BIG</li>
<li>And other&#8230;</li>
</ul>
<p>Microsoft tries to explain them <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7DFEB015-6043-47DB-8238-DC7AF89C93F1&amp;displaylang=en">here</a>, but generally, the descriptions of those errors might be unclear or even misleading. During the course of a week-long Kerberos issue troubleshooting, the problem was pinpointed to the following items.</p>
<ol>
<li><span style="font-weight:bold;">Internet Explorer settings on the client side.</span> Make sure that the client (using IE) has added your MOSS website to the list of Trusted Sites. This is done by going to the IE -&gt; Tools -&gt; Internet Options -&gt; Security -&gt; click on Trusted Sites -&gt; Click on the Sites button -&gt; type the url of the site and click Add. Also, make sure that the Security Level for the Trusted zone is Low. If that&#8217;s not possible, do a custom level (by pressing its button) and scroll down to the bottom of the pop up screen. Select  &#8220;User Authentication-&gt;Logon-&gt;Automatic logon with current user name and password&#8221; radio button. Basically this tells the browser to pass the user credentials to the web site. Otherwise it will pass some anonymous user and it will never work. <a href="http://hyankov.files.wordpress.com/2008/09/ie.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/ie.jpg?w=300" alt="" border="0" /></a></li>
<li>It is worth mentioning that <span style="font-weight:bold;">IE 6 won&#8217;t work with Kerberos</span>, if the web site is not running on port 80. It is explained in details <a href="http://support.microsoft.com/kb/908209">here</a>, but you can easily overcome this problem by using host headers, insted of ports.</li>
<li><span style="font-weight:bold;">Kerberos UDP fragmentation.</span> Yes, by default Kerberos is running over the unreliable UDP protocol. This means &#8211; there is no guarantee that the packages will actually reach the destination. So if you get a lot of KDC_ERR_S_PRINCIPAL_UNKNOWN and KRB_ERR_RESPONSE_TOO_BIG error logs, this might be the reason. It is explained <a href="http://technet.microsoft.com/en-us/library/cc779511.aspx">here</a> and the solution to that is right <a href="http://support.microsoft.com/kb/244474">here</a>. By setting the max packet size to 1, you force it to run over TCP. This will require reboot of the system, though.</li>
<li><span style="font-weight:bold;">Duplicate SPNs</span>. That is my favorite and less documented problem! To understand what is considered a duplicate, read <a href="http://geeks.netindonesia.net/blogs/jimmy/archive/2008/02/29/service-principal-name-headache.aspx">this</a> short article carefully! Turns out, you can not have &#8220;HTTP/portal.mydomain.com DOMAIN\ServiceA&#8221; <span style="font-weight:bold;">AND</span> &#8220;HTTP/portal.mydomain.com DOMAIN\ServiceB&#8221; in the same time! When you are adding a SPN, it should be assigned to only one user!</li>
</ol>
<p>Getting rid of the duplicate SPNs is no fun at all. Currently, there is no good tool do that for you. You will have to do it manually. First, you will need to output all the current SPNs in your domain. It&#8217;s all explained <a href="http://support.microsoft.com/kb/321044">here</a> (3rd method).
<ol>
<li>Get the spnquery.vbs script from <a href="http://www.filedropper.com/spnquery">here</a> (click on the download button)</li>
<li>Run it by executing &#8220;cscript spnquery.vbs * &gt; my_SPNs.txt&#8221; in the command prompt</li>
<li>Now you have all your SPNs dumped into the my_SPNs.txt file</li>
</ol>
<p>Open it in your favorite text editor for review. Let&#8217;s assume your MOSS server is called &#8220;SRV-MOSS&#8221; and your domain is &#8220;domain.company&#8221;. Search the file for &#8220;SRV-MOSS&#8221;. You should see an entry like:<br />
<blockquote>CN=SRV-MOSS,[...]<br />Class: computer<br />Computer DNS: [...]<br />&#8211; HOST/SRV-MOSS.domain.company<br />&#8211; HOST/SRV-MOSS</p></blockquote>
<p>It is fine. It shows that your MOSS server is trusted for delegation in the AD. Keep searching. You should see an entry similar to:<br />
<blockquote>CN=[Application Pool Running User],[...]<br />Class: user<br />User Logon: <span style="font-weight:bold;">[ApplicationPoolRunningUser]</span><br />&#8211; HTTP/SRV-MOSS<br />&#8211; HTTP/SRV-MOSS.domain.company</p></blockquote>
<p>If the [ApplicationPoolRunningUser] is the domain user, running your MOSS web application pool, that is great, because it means that you have set a correct SPN! If you don&#8217;t find such entries at all, you have missed an important step and you need to add delegation, by running command similar to:<br />
<blockquote>setspn -A HTTP/SRV-MOSS domain.company\ApplicationPoolRunningUser<br />setspn -A HTTP/SRV-MOSS.domain.company domain.company\ApplicationPoolRunningUser</p></blockquote>
<p>However, if you find another user entry (different of your MOSS app. pool running user), listing HTTP/SRV-MOSS as service principal name, that&#8217;s a problem, because it&#8217;s a duplicate! You will need to remove it by executing:<br />
<blockquote>setspn -D HTTP/SRV-MOSS domain.company\AnotherUser<br />setspn -D HTTP/SRV-MOSS.domain.company domain.company\AnotherUser</p></blockquote>
<p>Search for other duplicates and if none, you are one step closer to resolving the problem. At this moment, it is great idea to Purge all current Kerberos tickets in the system, as they (and the lack of?!) are being cached for more than 20 hours. For that purpose, you need to obtain a copy of the free KerbTray program. You might already have it installed, so check in your Program Files\Resource Kits. If not, get it from <a href="http://www.microsoft.com/downloads/details.aspx?familyid=4E3A58BE-29F6-49F6-85BE-E866AF8E7A88&amp;displaylang=en">here</a> and disregard it&#8217;s saying the program is for Windows 2000 only. Here is a tip &#8211; if you are lazy and don&#8217;t want to install it on all machines, you can intall it on one and access it from the others by opening \\servername\C$\&#8230; (if enabled). The program usually runs fine that way, worst case you will have to copy it.</p>
<p>So, after you start KerbTray you will notice a new green icon in the system tray.<br /><a href="http://hyankov.files.wordpress.com/2008/09/kerbtray_thumb.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/kerbtray_thumb.jpg?w=135" alt="" border="0" /></a></p>
<p>If you double click it will show you the current Kerberos tickets obtained for the system.<br /><a href="http://hyankov.files.wordpress.com/2008/09/kerb_window.gif"><img src="http://hyankov.files.wordpress.com/2008/09/kerb_window.gif?w=258" alt="" border="0" /></a></p>
<p>What you want to do is right click the icon and select &#8216;Purge Tickets&#8217;. Don&#8217;t worry, the system will obtain them again and that&#8217;s the whole point of the exercise.</p>
<p>Now go ahead and retest the network connectivity. Keep monitoring the K2 blackpearl server output. You should not see anonymous logons any more. Every network environment and its Kerberos configuration has something specific and its own flavor. Explore the references below to get further information and idea on how to troubleshoot Kerberos issues.</p>
<p><span style="font-weight:bold;">References:</span>
<ul>
<li><a href="http://geeks.netindonesia.net/blogs/jimmy/archive/2008/02/29/service-principal-name-headache.aspx">Understanding what is a Duplicate SPN!</a></li>
<li><a href="http://support.microsoft.com/kb/215383">How to configure IIS to support both the Kerberos protocol and the NTLM protocol for network authentication</a></li>
<li><a href="http://articles.techrepublic.com.com/5100-22_11-6111084.html?tag=rbxccnbtr1">Diagnosing Kerberos health issues, part 2</a></li>
<li><a href="http://www.k2underground.com/blogs/chrisg/archive/2008/06/16/kerberos-anyone.aspx">Multiple links to Kerberos resources</a></li>
<li><a href="http://www.digwin.com/view/moss-and-kerberos-configuration">Yet another MOSS/Kerberos article</a></li>
<li><a href="http://www.identitychaos.com/2008/03/problem-with-kerberos-delegation.html">Problems with Kerberos delegation</a></li>
<li><a href="http://support.microsoft.com/kb/908209">Internet Explorer 6 Kerberos bug (non port 80)</a></li>
<li><a href="http://blogs.msdn.com/spatdsg/archive/2007/11/14/kerberos-delegation-end-to-end-part-i.aspx">&#8220;Kerberos delegation .. end to end&#8221; Part I</a></li>
<li><a href="http://blogs.msdn.com/james_world/archive/2007/08/20/essential-guide-to-kerberos-in-sharepoint.aspx">Kerberos tips</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc779511.aspx">Kerberos running on UDP is unstable</a></li>
</ul>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=13&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2008/09/26/troubleshooting-kerberos-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2008/09/cerberus.jpg?w=288" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/blackpearlserver.png?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/ie.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/kerbtray_thumb.jpg?w=135" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/kerb_window.gif?w=258" medium="image" />
	</item>
		<item>
		<title>InfoPath 2007 Digitally Signed Form Templates</title>
		<link>http://hyankov.wordpress.com/2008/09/16/infopath-2007-digitally-signed-form-templates/</link>
		<comments>http://hyankov.wordpress.com/2008/09/16/infopath-2007-digitally-signed-form-templates/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 22:00:00 +0000</pubDate>
		<dc:creator>hyankov</dc:creator>
				<category><![CDATA[article]]></category>
		<category><![CDATA[blackpearl]]></category>
		<category><![CDATA[codebehind]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[hyankov]]></category>
		<category><![CDATA[infopath]]></category>
		<category><![CDATA[k2]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[signature]]></category>

		<guid isPermaLink="false">http://hyankov.wordpress.com/2008/09/16/infopath-2007-digitally-signed-form-templates</guid>
		<description><![CDATA[By Hristo Yankov If you are developing a K2 blackpearl / InfoPath 2007 / MOSS solution, at some point of time you might need to digitally sign your Form template. One of the reasons you may need to do that is, if you have to give &#8216;Full Trust&#8217; to the form. That&#8217;s because MOSS will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=12&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="font-style:italic;">By Hristo Yankov</span></p>
<p>If you are developing a K2 blackpearl / InfoPath 2007 / MOSS solution, at some point of time you might need to digitally sign your Form template. One of the reasons you may need to do that is, if you have to give &#8216;Full Trust&#8217; to the form. That&#8217;s because MOSS will not allow you to submit (or event start filling out) a new InfoPath form, which requires full trust but is not digitally signed.</p>
<p>The process is pretty straight-forward &#8211; in InfoPath you click on the Tools in menu, select &#8216;Form Options&#8217; and navigate to the &#8216;Security and Trust&#8217; tab.<br /><a href="http://hyankov.files.wordpress.com/2008/09/signature.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/signature.jpg?w=300" alt="" border="0" /></a><br />Then you click on the &#8216;Sign this form template&#8217; checkbox and choose a certificate (or create a new one).</p>
<p><span class="fullpost"><br />After doing this, you might be thinking that your InfoPath form is digitally signed and you can safely use the &#8216;Full Trust&#8217; settings. In reality, after you deploy your solution and attempt to create a new InfoPath form in the Form Library, you get the following error:</p>
<p><span style="color:rgb(255,0,0);">&#8220;The form template is trying to access files and settings on your computer. InfoPath cannot grant access to these files and settings because the form template is not fully trusted. For a form to run with full trust, it must be installed or digitally signed with a certificate.&#8221;</span></p>
<p><a href="http://hyankov.files.wordpress.com/2008/09/integrationicon.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/integrationicon.jpg?w=271" alt="" border="0" /></a><br />Now, let&#8217;s think about how we usually edit InfoPath forms, which are already integrated with the K2 process. Usually we click on the InfoPath integration icon which opens the wizard and then we click on the &#8216;Design&#8217; button, which opens the InfoPath application for us, so we can edit it.</p>
<p><span style="font-size:78%;">(InfoPath Integration Wizard)</span><br /><a href="http://hyankov.files.wordpress.com/2008/09/infopathintegration.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/infopathintegration.jpg?w=300" alt="" border="0" /></a></p>
<p>The problem with this approach is &#8211; by modifying the InfoPath form, K2 blackpearl invalidates your digital signature and effectively removes it. What happens is &#8211; you click on the &#8216;Design&#8217; button, open the InfoPath form, set the signature, save the form, close it, &#8216;Finish&#8217; the wizard, but next time you open the InfoPath form, your signature is gone. Even if you modify the InfoPath form outside the K2 studio, in the process of deployment, your signature is being destroyed again.</p>
<p>As a conclusion &#8211; there is no way you can deploy digitally signed InfoPath form, through the K2 blackpearl studio!</p>
<p>Fortunately there is a work-around. After deploying your solution, follow these steps:
<ol>
<li>Navigate to your MOSS website</li>
<li>Navigate to your Form Library where the form was deployed</li>
<li>Click on Settings -&gt; Form Library Settings</li>
<li><a href="http://hyankov.files.wordpress.com/2008/09/portal1.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/portal1.jpg?w=300" alt="" border="0" /></a></li>
<li>Click on the &#8216;Advanced settings&#8217; link</li>
<li><a href="http://hyankov.files.wordpress.com/2008/09/advancedsettings.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/advancedsettings.jpg?w=300" alt="" border="0" /></a></li>
<li>Click on &#8216;Edit template&#8217; link (Select &#8216;Yes&#8217; at the question, if any)</li>
<li><a href="http://hyankov.files.wordpress.com/2008/09/edittemplate.jpg"><img src="http://hyankov.files.wordpress.com/2008/09/edittemplate.jpg?w=300" alt="" border="0" /></a></li>
<li>It will open the InfoPath form in design mode for you and will prompt you to save it somewhere. Don&#8217;t overwrite the InfoPath form which is in the K2 project. Just save this on the desktop, or somewhere else.</li>
<li>Now, in the InfoPath go to the Tool -&gt; Form Options&#8230; -&gt; Security and Trust and select full trust radio-button.</li>
<li>On the same screen &#8211; sign the form</li>
<li>Save the InfoPath on the desktop again</li>
<li>Use the Publishing wizard in the InfoPath application (File -&gt; Publish&#8230;) to republish the form into the form library.</li>
</ol>
<p>Now your InfoPath form is digitally signed and ready to use. Unfortunately, you will have to follow those steps after each deployment.</p>
<p></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/hyankov.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/hyankov.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hyankov.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hyankov.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hyankov.wordpress.com&#038;blog=12474033&#038;post=12&#038;subd=hyankov&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hyankov.wordpress.com/2008/09/16/infopath-2007-digitally-signed-form-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/60f8be1907b4d9c4d1c4a6a4b0556bc7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">hyankov</media:title>
		</media:content>

		<media:content url="http://hyankov.files.wordpress.com/2008/09/signature.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/integrationicon.jpg?w=271" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/infopathintegration.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/portal1.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/advancedsettings.jpg?w=300" medium="image" />

		<media:content url="http://hyankov.files.wordpress.com/2008/09/edittemplate.jpg?w=300" medium="image" />
	</item>
	</channel>
</rss>
