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

<channel>
	<title>Code For Future &#187; reusable code</title>
	<atom:link href="http://codeforfuture.com/category/reusable-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeforfuture.com</link>
	<description>Share as you code.</description>
	<lastBuildDate>Mon, 08 Aug 2011 05:41:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>How to compare dates using XSLT and find the largest one?</title>
		<link>http://codeforfuture.com/2011/03/16/how-to-compare-dates-using-xslt-and-find-the-largest-one/</link>
		<comments>http://codeforfuture.com/2011/03/16/how-to-compare-dates-using-xslt-and-find-the-largest-one/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 15:40:00 +0000</pubDate>
		<dc:creator>Jayvardhan Patil</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[XSLT Code Samples]]></category>
		<category><![CDATA[reusable code]]></category>
		<category><![CDATA[Date comparision]]></category>

		<guid isPermaLink="false">http://codeforfuture.com/2011/03/16/how-to-compare-dates-using-xslt-and-find-the-largest-one/</guid>
		<description><![CDATA[While working in SharePoint dataviews, we need to compare dates several times to find out a larger one. While I wondered around this and I see there is no direct function to do this. I found a workaround which I generally use. &#160; 1. Create 2 variables from dates. I’m converting both dates to US [...]]]></description>
			<content:encoded><![CDATA[<p>While working in SharePoint dataviews, we need to compare dates several times to find out a larger one. While I wondered around this and I see there is no direct function to do this.</p>
<p>I found a workaround which I generally use. </p>
<p>&#160;</p>
<p><strong>1. Create 2 variables from dates.</strong> I’m converting both dates to US format and then to a number with year, month and date sequence to ensure correctness.</p>
<p>&#160;</p>
<p>&lt;xsl:variable name=&quot;ExpiryDate1&quot; select=&quot;number(ddwrt:FormatDateTime(string(@ExpirationDate), 1033, &#8216;yyyyMMdd&#8217;))&quot;/&gt;</p>
<p>&lt;xsl:variable name=&quot;OtherDate2&quot; select=&quot;number(ddwrt:FormatDateTime(string(@OtherDate), 1033, &#8216;yyyyMMdd&#8217;))&quot;/&gt;</p>
<p>&#160;</p>
<p><strong>2. Compare</strong> them to find out which one is greater</p>
<p>&lt;xsl:choose&gt;   <br />&lt;xsl:when test=’ExpirationDate-OtherDate &gt;= 0&#8242;&gt;</p>
<p>&#160;&#160; // Do Something   <br />&lt;/xsl:when&gt;    <br />&lt;xsl:otherwise&gt;&#160; </p>
<p>&#160; // Do Something</p>
<p>&lt;/xsl:otherwise&gt;   <br />&lt;/xsl:choose&gt;</p>
<p>&#160;</p>
<p>I don’t claim that this the best solution I have got, while it works very well. If you know anything better, please share!</p>
]]></content:encoded>
			<wfw:commentRss>http://codeforfuture.com/2011/03/16/how-to-compare-dates-using-xslt-and-find-the-largest-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to remove link for SharePoint lookup column from a DataView WebPart using XSLT</title>
		<link>http://codeforfuture.com/2011/03/15/how-to-remove-link-for-sharepoint-lookup-column-from-a-dataview-webpart-using-xslt/</link>
		<comments>http://codeforfuture.com/2011/03/15/how-to-remove-link-for-sharepoint-lookup-column-from-a-dataview-webpart-using-xslt/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 15:18:14 +0000</pubDate>
		<dc:creator>Jayvardhan Patil</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[XSLT Code Samples]]></category>
		<category><![CDATA[reusable code]]></category>
		<category><![CDATA[dataview]]></category>
		<category><![CDATA[lookup columns]]></category>

		<guid isPermaLink="false">http://codeforfuture.com/2011/03/15/how-to-remove-link-for-sharepoint-lookup-column-from-a-dataview-webpart-using-xslt/</guid>
		<description><![CDATA[Whenever we use a lookup column into the dataview or listview, it displays a link to the lookup item it is referring to. This is the same behavior you see on the backend list views. But sometimes we just need to show data on page and do not need the link to the lookup item. [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever we use a lookup column into the dataview or listview, it displays a link to the lookup item it is referring to. This is the same behavior you see on the backend list views. But sometimes we just need to show data on page and do not need the link to the lookup item.</p>
<p>Setting disable-output-escaping=&quot;no&quot; doesn’t work in this case, because then it displays the HTML coding for the link (‘a’ tag).</p>
<p>The easiest solution to get rid of ‘A’ tag is to remove it completely using sub-string function.</p>
<p>For example if you are showing a column named “Category”, in this case you can replace </p>
<p>&lt;xsl:value-of select=&quot;@Category&quot; disable-output-escaping=&quot;yes&quot;/&gt;</p>
<p>&#160;</p>
<p>with </p>
<p>&#160;</p>
<p>&lt;xsl:value-of select=&quot;substring-before(substring-after(@Category, &#8216;&amp;gt;&#8217;), &#8216;&amp;lt;&#8217;)&quot; disable-output-escaping=&quot;yes&quot;/&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://codeforfuture.com/2011/03/15/how-to-remove-link-for-sharepoint-lookup-column-from-a-dataview-webpart-using-xslt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>using RichTextBox control in Sharepoint MOSS 2007</title>
		<link>http://codeforfuture.com/2008/12/03/using-richtextbox-control-in-sharepoint-moss-2007/</link>
		<comments>http://codeforfuture.com/2008/12/03/using-richtextbox-control-in-sharepoint-moss-2007/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 05:26:00 +0000</pubDate>
		<dc:creator>Jayvardhan Patil</dc:creator>
				<category><![CDATA[MOSS 2007]]></category>
		<category><![CDATA[reusable code]]></category>

		<guid isPermaLink="false">http://codeforfuture.com/2008/12/03/using-richtextbox-control-in-sharepoint-moss-2007/</guid>
		<description><![CDATA[Like me you too came searching for the RichTextField control for SharePoint. But you will be surprised that this is not the one you are looking for. You must be looking for a control which will allow you to create formatted text as shown in below given image. InputFormTextBox is the correct control you will [...]]]></description>
			<content:encoded><![CDATA[<p>Like me you too came searching for the RichTextField control for SharePoint. But you will be surprised that this is not the one you are looking for. </p>
<p>You must be looking for a control which will allow you to create formatted text as shown in below given image.</p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_xm5KTL2VzWo/STYs3UcFCiI/AAAAAAAABCI/sFgFuNTju3A/s1600-h/InputFormTextBox+Control.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 337px; height: 163px;" src="http://3.bp.blogspot.com/_xm5KTL2VzWo/STYs3UcFCiI/AAAAAAAABCI/sFgFuNTju3A/s400/InputFormTextBox+Control.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5275453342402021922" /></a></p>
<p>InputFormTextBox is the correct control you will ever need. This is available under Microsoft.SharePoint.WebControls namespace. (Only MOSS 2007)</p>
<p>How to use it? Very simple.</p>
<blockquote><p>InputFormTextBox richMessage = new InputFormTextBox();<br />richMessage.RichText = true;<br />richMessage.RichTextMode = SPRichTextMode.FullHtml;</p></blockquote>
<p>You may also use following useful properties:</p>
<blockquote><p>richMessage.AllowHyperlink = true;<br />richMessage.TextMode = TextBoxMode.MultiLine;<br />richMessage.Wrap = true;<br />richMessage.Rows = 10;<br />richMessage.Width = System.Web.UI.WebControls.Unit.Percentage(100);</p></blockquote>
<p>Check another thread for known issues with InputFormTextBox Control.<br /><a href="http://code.jaypatil.com/2008/12/inputformtextbox-width-enabled-readonly.html">InputFormTextBox width, Enabled, ReadOnly Properties not working properly</a><br />
<br/><br />
<span style="font-weight:bold;"><br />
If you found this post helpful then please share it.<br />
</span></p>
<p><a href="http://hub.tm/?IgjDe"><br />
<img border="0" target="_new" src="http://twitter.grader.com/assets/img/tweet-it-button.jpg" alt="TweetIt from HubSpot" title=""/><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codeforfuture.com/2008/12/03/using-richtextbox-control-in-sharepoint-moss-2007/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Collection was modified; enumeration operation may not execute</title>
		<link>http://codeforfuture.com/2008/12/01/collection-was-modified-enumeration-operation-may-not-execute/</link>
		<comments>http://codeforfuture.com/2008/12/01/collection-was-modified-enumeration-operation-may-not-execute/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 12:35:00 +0000</pubDate>
		<dc:creator>Jayvardhan Patil</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MS.NET]]></category>
		<category><![CDATA[reusable code]]></category>

		<guid isPermaLink="false">http://codeforfuture.com/2008/12/01/collection-was-modified-enumeration-operation-may-not-execute/</guid>
		<description><![CDATA[Collection was modified; enumeration operation may not execute This exception is thrown when you are trying to delete items of a collection in a for loop or using a for each loop. The ideal solution could be to use a for loop with a descending counter. Problem: for e.g. If suppose you are executing any [...]]]></description>
			<content:encoded><![CDATA[<p>Collection was modified; enumeration operation may not execute</p>
<p>This exception is thrown when you are trying to delete items of a collection in a for loop or using a for each loop.</p>
<p>The ideal solution could be to use a for loop with a descending counter.</p>
<p>Problem:</p>
<p>for e.g. </p>
<p>If suppose you are executing any of following code snippets</p>
<p>1.</p>
<p>for (int listcounter = 0; listcounter < ReferenceOwnersList.Items.Count; listcounter++)<br />{<br /> ReferenceOwnersList.Items.Delete(0);<br />}</p>
<p>2.</p>
<p>foreach (SPListItem Li in ReferenceOwnersList.Items)<br />{<br /> Li.Delete();<br />}</p>
<p>Here ReferenceOwnersList is a collection.</p>
<p>Now whenever this code will execute for the first time, the number of items reduce. So the second item gets the first index.<br />I tried deleting 0th item everytime but still I got the exception. Again changing index may cause skipping the items in most senerios.</p>
<p>And the collection throws the &#8220;Collection was modified; enumeration operation may not execute&#8221; exception.</p>
<p>Solution:</p>
<p>Solution <br />Use a reducing for loop.</p>
<p>for (int cntLi = ReferenceOwnersList.Items.Count &#8211; 1; cntLi >=0 ;cntLi &#8212; )<br />{<br /> ReferenceOwnersList.Items.Delete(cntLi);<br />}</p>
<p>so that even if the last item is deleted, the index of other items wont change.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeforfuture.com/2008/12/01/collection-was-modified-enumeration-operation-may-not-execute/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Welcome</title>
		<link>http://codeforfuture.com/2008/06/25/welcome/</link>
		<comments>http://codeforfuture.com/2008/06/25/welcome/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 12:37:00 +0000</pubDate>
		<dc:creator>Jayvardhan Patil</dc:creator>
				<category><![CDATA[reusable code]]></category>

		<guid isPermaLink="false">http://codeforfuture.com/2008/06/25/welcome/</guid>
		<description><![CDATA[Hi, I&#8217;m Jay. Welcome to my blog. I have created this blog to share my experiences while working on different technologies. The theme for this blog is &#8220;Coding for future&#8221;. Coding for future is all about reducing the time required for software development. The ways I have figured out is; Building reusable code, and making [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;m Jay. Welcome to my blog. I have created this blog to share my experiences while working on different technologies.</p>
<p>The theme for this blog is &#8220;Coding for future&#8221;.</p>
<p>Coding for future is all about reducing the time required for software development.</p>
<p>The ways I have figured out is;</p>
<p>Building reusable code, and making it public!</p>
<p>Though practically exposing code could be harmful to some organizations, programmers can sharing technical issues faced and their solutions!</p>
<p>I believe if 80% of the issues and solutions are shared then we will see a rapid application development and we will soon be building more complex solutions that world is actually going to see may be 50 years later.</p>
<p>This is &#8220;coding for future&#8221; all about!.</p>
]]></content:encoded>
			<wfw:commentRss>http://codeforfuture.com/2008/06/25/welcome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

