<?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>Yappitty Yap</title>
	<atom:link href="http://kalpeshshirodker.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kalpeshshirodker.wordpress.com</link>
	<description>"Lead, follow, or get out of the way."</description>
	<lastBuildDate>Wed, 18 Jan 2012 10:31:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kalpeshshirodker.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Yappitty Yap</title>
		<link>http://kalpeshshirodker.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kalpeshshirodker.wordpress.com/osd.xml" title="Yappitty Yap" />
	<atom:link rel='hub' href='http://kalpeshshirodker.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Querying XML in Javascript</title>
		<link>http://kalpeshshirodker.wordpress.com/2012/01/18/querying-xml-in-javascript/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2012/01/18/querying-xml-in-javascript/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 10:31:20 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/?p=164</guid>
		<description><![CDATA[The most important aspects of using XML is its usability, readability and the ability to search for information contained in the document. There are various ways to implement the searching/querying the XML document depending on the type of language you would use. The most widely used method for querying an XML document is XPATH. XPath [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=164&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The most important aspects of using XML is its usability, readability and the ability to search for information contained in the document. There are various ways to implement the searching/querying the XML document depending on the type of language you would use.</p>
<p>The most widely used method for querying an XML document is XPATH. XPath is a well defined query language especially defined for XML documents. All languages support the XPath syntax in one format or the other, and it also has a very well defined implementation in JavaScript as well.</p>
<p>One of the best resources i found over the net is the following one : <a href="http://www.ibm.com/developerworks/xml/library/x-xpathjquery/index.html?ca=drs-">Choose between XPath and jQuery with an XPath-jQuery phrase book</a>. It describes 2 different methodologies, one is using XPath and the other is using jQuery. Definitely a must read and able guide to your arsenal.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=164&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2012/01/18/querying-xml-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>IE and XMLHTTPRequest overrideMimeType dilemma</title>
		<link>http://kalpeshshirodker.wordpress.com/2012/01/09/ie-and-xmlhttprequest-overridemimetype-dilemma/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2012/01/09/ie-and-xmlhttprequest-overridemimetype-dilemma/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 13:35:45 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[Internet at large]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/?p=158</guid>
		<description><![CDATA[“Bummer! and IE does it again!!!” I thought, actually that was the first thought that came to my mind and boy was i right about it. I should have been accustomed to all this intricacies and little nuggets here and there, which IE tends to reveal once more often than not. I will tell you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=158&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>“Bummer! and IE does it again!!!” I thought, actually that was the first thought that came to my mind and boy was i right about it. I should have been accustomed to all this intricacies and little nuggets here and there, which IE tends to reveal once more often than not. </p>
<p>I will tell you what hit me this time, its the ubiquitous XMLHTTPRequest, that small piece of function which is the forerunner of all things magic about AJAX in HTML5. I tell you, its a very simple problem, now i have a servlet which spits out some response for all the world to consume. When I say “I have” it is not “I Have”, it is like “I have access to”, because I cannot change the output, OK?, right!. </p>
<p>But now i am able to connect and receive the response, we are very fine till here, no problems (I can see it in fiddler, so i am not lying about that). But the problem is I am not able to access the information in javascript, the data is truncated. Why? i tell you why, because the response is a delimited string, delimited using null terminator (that’s how it is <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ). </p>
<p>Rummaging through the web i found that there are problems with AJAX when the response contains a null terminator, but which can be overcome by overriding the mime type for the AJAX response, using <strong>“xmlHttpReq.overrideMimeType”</strong> function, but guess what the IE doesnt support the function. I ask you why? why wouldnt IE support it? Its more than I can fathom, but such are the strange ways of IE and they want me to patch the servlet to send appropriate mime-type. </p>
<p>Now, I am left with patching the servlet (which is outside the scope) and moreover i dont have access to. Bummer, grumble grumble grumble!!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=158&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2012/01/09/ie-and-xmlhttprequest-overridemimetype-dilemma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Developer resource &#8211; Cheat Codes</title>
		<link>http://kalpeshshirodker.wordpress.com/2011/10/18/developer-resource-cheat-codes/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2011/10/18/developer-resource-cheat-codes/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 10:00:45 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://kalpeshshirodker.wordpress.com/?p=152</guid>
		<description><![CDATA[More often than not as we go through our daily chore of coding, we usually get stuck at some trivial scenario, where we get lost as to what is the next logical statement to be written. Or you may get totally lost as to what needs to be done and how to go about achieving [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=152&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>More often than not as we go through our daily chore of coding, we usually get stuck at some trivial scenario, where we get lost as to what is the next logical statement to be written. Or you may get totally lost as to what needs to be done and how to go about achieving the results for the given problem. Sounds familiar? Happens often to me, that&#8217;s why when i stumbled upon this site, it was answer to my prayers. </p>
<p>For all the lost souls, this is the first place of knocking <a href="http://devcheatsheet.com/" title="http://devcheatsheet.com/" target="_blank">http://devcheatsheet.com/</a>. It has a host of Cheat codes ranging over a wide programming section. Go check it out.</p>
<p>Happy coding</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=152&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2011/10/18/developer-resource-cheat-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing Session from Javascript using JQuery, AJAX in ASP.Net</title>
		<link>http://kalpeshshirodker.wordpress.com/2010/12/25/accessing-session-from-javascript-using-jquery-ajax-in-asp-net/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2010/12/25/accessing-session-from-javascript-using-jquery-ajax-in-asp-net/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 10:23:18 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/2010/12/25/accessing-session-from-javascript-using-jquery-ajax-in-asp-net/</guid>
		<description><![CDATA[Well, well well, this is one of those problems which crops out many a time while developing web application “How do i access session variables in my Javascript?” Usually the answer is you cannot, simply because sessions are stored on the server and your application is running on some remote client. Theoretically that is truth, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=139&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, well well, this is one of those problems which crops out many a time while developing web application “How do i access session variables in my Javascript?” Usually the answer is you cannot, simply because sessions are stored on the server and your application is running on some remote client. Theoretically that is truth, but not the whole truth. Let us dispel the misconception.</p>
<p>&#160;</p>
<h3>Accessing session variables in ASP.Net</h3>
<p>Well as we said before, it is not completely true when someone tells you, that session values cannot be used in JavaScript. It can be done, but with limitations. You can only have read-only access <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is how we do it</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode"><span class="kwrd">//Consider you have set the following session variable in code-behind</span></pre>
<pre class="csharpcode"><span class="kwrd">//Session[“UserName”] = “kalpesh”</span></pre>
<pre class="csharpcode"><span class="kwrd">function</span> PrintUserName()
{
<span class="kwrd">var</span> sv = <span class="str">'&lt;%= Session[&quot;UserName&quot;] %&gt;'</span>
} </pre>
<pre class="csharpcode">&#160;</pre>
<pre class="csharpcode">//When you execute the aspx page; the value should be replaced by the session value</pre>
<pre class="csharpcode">//e.g. var sv = ‘kalpesh’</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Pretty simple isnt it? For most purposes this will do just fine. Where the value is largely static i.e. it doesn’t change much often we can just get by with no issues. What do you do for values which are constantly modified and need to be displayed to the user, without forcing the user to refresh the page?</p>
<p>&#160;</p>
<h3>Accessing session variables using AJAX</h3>
<p>As the question states, we are in a soup when we need to display constantly modifying values. If we have to force the user to modify, you can very well guess what can happen? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Despite the popular belief it is quite easy to access session values using AJAX, if you know where to look <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  (I have been hunting for it for quite a while, before having a deja vu <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>All we need to do is create an asmx Web Service which exposes the desired method as shown below</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode">//The important part is “EnableSession = <span class="kwrd">true</span>”</pre>
<pre class="csharpcode">[WebMethod(EnableSession = <span class="kwrd">true</span>)]
<span class="kwrd">public</span> <span class="kwrd">string</span> GetSessionValue(String Name)
{
    <span class="kwrd">string</span> sessionVal = String.Empty;
    <span class="kwrd">if</span> (Session != <span class="kwrd">null</span> &amp;&amp; Session[Name] != <span class="kwrd">null</span>)
    {
        sessionVal = Session[Name].ToString();
    }
    <span class="kwrd">return</span> sessionVal;
}</pre>
</td>
</tr>
</tbody>
</table>
<pre class="csharpcode">&#160;</pre>
<h3>Invoking web service methods using JQuery</h3>
<p>Calling our web method from javascript is very easy. There are a whole lot of tutorials around so i wont get into details. </p>
<p>I have can implemented a generic method to due the AJAX calls offloading for me</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode">&#160;</pre>
<pre class="csharpcode"><span class="kwrd">var</span> webMethod_result;
<span class="kwrd">function</span> WebMethod_OnError(result, response)
{
    <span class="rem">//debugger</span>
    <span class="rem">//Dummy function for page method ajax call</span>
}
<span class="kwrd">function</span> WebMethod_OnSuccess(result, response)
{
    <span class="rem">//Dummy function for page method ajax call</span>
    webMethod_result = result.d;
}

<span class="kwrd">function</span> CallWebMethod(MethodName, ObjParams, isAsync, OnSuccessHandler, OnErrorHandler)
{
    <span class="kwrd">try</span>
    {
    <span class="rem">//Set the callback methods for success and error</span>
    <span class="kwrd">if</span> (OnSuccessHandler == undefined || <span class="kwrd">typeof</span> (OnSuccessHandler) == <span class="str">&quot;undefined&quot;</span>)
    {
        OnSuccessHandler = WebMethod_OnSuccess
    }

    <span class="kwrd">if</span> (OnErrorHandler == undefined || <span class="kwrd">typeof</span> (OnErrorHandler) == <span class="str">&quot;undefined&quot;</span>)
    {
        OnErrorHandler = WebMethod_OnError
    }

    <span class="rem">//Serialize the webmethod function parameters</span>
    <span class="kwrd">var</span> serializedParams = <span class="str">&quot;&quot;</span>;</pre>
<pre class="csharpcode">//using Json2.js; </pre>
<pre class="csharpcode">//you can download the file from the location mentioned in the references
   serializedParams = JSON.stringify(ObjParams); </pre>
<pre class="csharpcode">    <span class="rem">//Make the ajax calls</span>
    <span class="kwrd">return</span> $.ajax(
        {
        type: <span class="str">&quot;POST&quot;</span>,
        async: isAsync,
        url: <span class="str">&quot;TestJQueryWebservice.asmx/&quot;</span> + MethodName,
        data: serializedParams,
        dataType: <span class="str">&quot;json&quot;</span>,
        contentType: <span class="str">&quot;application/json; charset=utf-8&quot;</span>,
        success: OnSuccessHandler,
        error: OnErrorHandler
        });
    }
    <span class="kwrd">catch</span> (e)
    {
    <span class="rem">//suppress error</span>
    }

    <span class="kwrd">return</span>;
}</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>The next stop is to define proxy methods which can be called from our javascript function</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode"><span class="rem">//Proxy method for getting the Session value for a given name </span>

function GetSessionValue(SessionName, OnSuccessHandler, OnErrorHandler)
        {
            <span class="rem">//set web method parameters; should be same as parameter name else the web </span></pre>
<pre class="csharpcode"><span class="rem">            //method wont be called </span>
            var methodParams = <span class="kwrd">new</span> Object();
            methodParams.Name = SessionName; 

            CallWebMethod(<span class="str">&quot;GetSessionValue&quot;</span>, methodParams, <span class="kwrd">false</span>, OnSuccessHandler, OnErrorHandler); 

            <span class="rem">//get the response </span>
            <span class="kwrd">return</span> webMethod_result;
        }
 </pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>And calling the method from javascript? Easy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode"><span class="kwrd">var</span> sessionVal; 

sessionVal = GetSessionValue(<span class="str">&quot;TestJQuery&quot;</span>);</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Nice <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#160; </p>
<h3>Modifying session variables</h3>
<p>Its pretty simple to add a method to modify the session variables. Well this is how you do it.</p>
<p>The web method</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode">[WebMethod(EnableSession = <span class="kwrd">true</span>)]
        <span class="kwrd">public</span> <span class="kwrd">void</span> SetSessionValue(String Name, String Value)
        {
            <span class="kwrd">string</span> sessionVal = String.Empty;

            <span class="kwrd">if</span> (Session != <span class="kwrd">null</span>)
            {
                Session[Name] = Value;
            }
        }</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>The proxy method</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode"><span class="kwrd">function</span> SetSessionValue(SessionName, SessionValue, OnSuccessHandler, OnErrorHandler)
        {
            <span class="rem">//set web method parameters; should be same as parameter name else the web method wont be called</span>
            <span class="kwrd">var</span> methodParams = <span class="kwrd">new</span> Object();

            methodParams.Name = SessionName;
            methodParams.Value = SessionValue;

            CallWebMethod(<span class="str">&quot;SetSessionValue&quot;</span>, methodParams, <span class="kwrd">false</span>, OnSuccessHandler, OnErrorHandler);
        }</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>And the call from javascript</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<pre class="csharpcode"><span class="rem">//update session value</span>
SetSessionValue(<span class="str">&quot;TestJQuery&quot;</span>, <span class="str">&quot;UpdatedValue&quot;</span>);</pre>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Sweet. It can’t get better than this.</p>
<p>Until then, Happy coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#160;</p>
<h3>Refrences</h3>
<p><a title="jQuery.ajax()" href="http://api.jquery.com/jQuery.ajax/" target="_blank" rel="jQuery.ajax()">jQuery.ajax()</a></p>
<p><a title="json2.js : JSON library by Douglas Crockford" href="https://github.com/douglascrockford/JSON-js" target="_blank" rel="json2.js : JSON library by Douglas Crockford">json2.js : JSON library by Douglas Crockford</a></p>
<p><a title="JSON Home" href="http://www.json.org/" target="_blank" rel="JSON Home">JSON Home</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=139&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2010/12/25/accessing-session-from-javascript-using-jquery-ajax-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying formatted text in a Label</title>
		<link>http://kalpeshshirodker.wordpress.com/2010/12/21/displaying-formatted-text-in-a-label/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2010/12/21/displaying-formatted-text-in-a-label/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 05:10:05 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[User Controls]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/?p=117</guid>
		<description><![CDATA[Recently while working on some project of mine, i came across an interesting problem (not that it was problem actually, just may be a dilemma), so it got me thinking. The problem was to display formatted text in a label, as you must have already guessed by reading the title. The solution for it is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=117&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently while working on some project of mine, i came across an interesting problem (not that it was problem actually, just may be a dilemma), so it got me thinking. The problem was to display formatted text in a label, as you must have already guessed by reading the title.</p>
<p>The solution for it is very simple, if you ask me and the solution is very much acceptable <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , then you may ask why are we bothered about the problem at all? for one I was feeling bored and wanted to do something interesting <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  and two, this clears a lot of clutter from the application <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><font size="3"><strong>The Simple Solution</strong></font></p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="454">lblText.Text = String.Format(&quot;Age is : {0}&quot;, &quot;78&quot;); //this is a hypothetical example</td>
</tr>
</tbody>
</table>
<p>In most cases this will be very acceptable, but some more of those String.Format functions and your code starts to clutter up. Moreover, this will permanently change the text property of the label, so you wont be able to retrieve the original value “78”, if you wanted to <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><font size="3"><strong>The Elegant Solution</strong></font></p>
<p>Create a user control which inherits from Label Control, exposing additional property</p>
<p>&#160;</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<p>public virtual String FormatString            <br />&#160;&#160;&#160;&#160;&#160;&#160; {             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p>//get the value stored in the viewstate; Default Empty string</p>
<p>//Need to check the viewstate for nulls&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return ViewState.GetValue(&quot;FormatString&quot;,String.Empty);             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p>//save the value to viewstate            <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ViewState.SetValue(&quot;FormatString&quot;, value);             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }             <br />&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</td>
</tr>
</tbody>
</table>
<p>Which can then be used as follows.</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">lblText.FormatString = &quot;Age is : {0}&quot;;          <br />lblText.Text = “78”; //this is a hypothetical example</td>
</tr>
</tbody>
</table>
<p>How about that? A little better, but we can do better, we can set the format string in the aspx/ascx and set the text property in the code behind.</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">&lt;cc1:FormatedLabel runat=&quot;server&quot; ID=&quot;lblFormatString&quot; Text=&quot;89&quot; FormatString=&quot;Age is : {0}&quot;&gt;&lt;/cc1:FormatedLabel&gt;          </p>
<p>//Code behind           <br />lblFormatString.Text = “78”; </td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p><font size="3"><strong>Formatting Numeric types</strong></font></p>
<p>Things started to get little exciting when we try to format numeric data i.e. int, floats etc. What would you do to display numeric data in exponential format e.g.”1.052033e+003” for a given text “1052.0329112756”. Hmmmmm.</p>
<p>The String.Format function formats the string based on a given format string provided, the object on which the formatting is to be performed supports it. Pretty heavy stuff, huh. In simple words it means format string “{0:e}” for instance, is only applicable when you are using a numeric datatype. See below</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="400">String frmtString = “{0:e}”;          <br />String formattedString = String.Empty;           </p>
<p>String sVal =”78”;           </p>
<p>formattedString&#160; = String.Format(frmtString ,sVal ); //will not format as expected; output will be “78”           </p>
<p>int iVal = “89”;           <br />formattedString&#160; = String.Format(frmtString ,iVal ); //format as expected; output will be “8.900000e+001”           </p>
</td>
</tr>
</tbody>
</table>
<p>So if we try to do the following, it wont work</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">&lt;cc1:FormatedLabel runat=&quot;server&quot; ID=&quot;lblFormatString&quot; Text=&quot;1052.0329112756&quot; FormatString=&quot;{0:e}&quot;&gt;&lt;/cc1:FormatedLabel&gt;          </p>
<p>//output           <br />1052.0329112756</td>
</tr>
</tbody>
</table>
<p>This wont work because the text property contains string data type and string data type does not support “e” format, that format is specific to numeric data type. So how do we get around this problem? One solution which immediately came to my mind is specify the Data Type for formatting</p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">
<p>public enum DataType            <br />{             <br />&#160;&#160;&#160; String,             <br />&#160;&#160;&#160; Numeric,             <br />&#160;&#160;&#160; DateTime,             <br />&#160;&#160;&#160; Boolean             <br />}</p>
<p>public DataType DataType            <br />&#160;&#160;&#160;&#160;&#160;&#160; {             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return ViewState.GetValue(&quot;DataType&quot;, DataType.String);             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ViewState.SetValue(&quot;DataType&quot;, value);             <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }             <br />&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</td>
</tr>
</tbody>
</table>
<p>I have added support/made provisions for other datatypes as well <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You can add more if you want to.</p>
<p>Cool, now we are getting somewhere. Now you can do the following and you should get see the expected result <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table cellspacing="0" cellpadding="2" width="100%" border="1">
<tbody>
<tr>
<td valign="top" width="100%">&lt;cc1:FormatedLabel runat=&quot;server&quot; ID=&quot;lblFormatString&quot; Text=&quot;1052.0329112756&quot; FormatString=&quot;{0:e}&quot; DataType=&quot;Numeric&quot;&gt;&lt;/cc1:FormatedLabel&gt;          </p>
<p>//Output           <br />1.052033e+003</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Voila, this is neat.</p>
<p>&#160;</p>
<p><font size="3"><strong>String to DataType Conversion</strong></font></p>
<p>Its a little bit tricky when you have to convert the data from string to actual data type, for this small control it is not an issue. The way i got about it is by using TypeDescriptor and TypeConverters classes <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Its a simple control, but may be very useful. Happy coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><font size="3"><strong>Source Code</strong></font></p>
<p>If you are interested, you can get the source code from the link provided. </p>
<p><strong>NOTE :-</strong> Please note that the source code is in a zip file. Due to some restriction by WordPress.com, i have renamed the file as “FormattedLabel.zip.pdf”.</p>
<p><a href="http://kalpeshshirodker.files.wordpress.com/2010/12/formatedlabel-zip.pdf">Download Source</a></p>
<p>&#160;</p>
<p><strong><font size="3">References</font></strong></p>
<p><a title="MSDN : TypeDescriptor Class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typedescriptor.aspx" target="_blank" rel="MSDN : TypeDescriptor Class">MSDN : TypeDescriptor Class</a></p>
<p><a title="MSDN : TypeConverter Class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter.aspx" target="_blank" rel="MSDN : TypeConverter Class">MSDN : TypeConverter Class</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=117&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2010/12/21/displaying-formatted-text-in-a-label/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>How To [SQL] : Convert Binary String to Integer value</title>
		<link>http://kalpeshshirodker.wordpress.com/2010/10/23/how-to-sql-convert-binary-string-to-integer-value/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2010/10/23/how-to-sql-convert-binary-string-to-integer-value/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 07:01:55 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/2010/10/23/how-to-sql-convert-binary-string-to-integer-value/</guid>
		<description><![CDATA[Recently i came across a very trivial but an interesting problem. The problem was how to convert a string representing a binary value to its corresponding integer value in SQL. I searched high and dry on the net, but was faced with no luck of finding an inbuilt method to accomplish the task. So reluctantly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=116&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently i came across a very trivial but an interesting problem. The problem was how to convert a string representing a binary value to its corresponding integer value in SQL. I searched high and dry on the net, but was faced with no luck of finding an inbuilt method to accomplish the task.</p>
<p>So reluctantly i set out of doing it my own way. After a couple of false starts i came up with this solution. Pretty simple and elegant, more importantly effective.</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:650px;border-bottom:#cecece 1px solid;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><span style="color:#008000;">/****** Object:  UserDefinedFunction [dbo].[UDF_BinarytoInt]    Script Date: 10/04/2010 20:47:36 ******/</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=IF&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">IF</a>  <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=EXISTS&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">EXISTS</a> (<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> * <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> sys.objects <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> object_id = OBJECT_ID(N'<span style="color:#8b0000;">[dbo].[UDF_BinarytoInt]</span>') <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AND&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AND</a> TYPE <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=in&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">in</a> (N'<span style="color:#8b0000;">FN</span>', N'<span style="color:#8b0000;">IF</span>', N'<span style="color:#8b0000;">TF</span>', N'<span style="color:#8b0000;">FS</span>', N'<span style="color:#8b0000;">FT</span>'))
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=DROP&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">DROP</a> <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FUNCTION&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FUNCTION</a> [dbo].[UDF_BinarytoInt]
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=GO&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">GO</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><span style="color:#008000;">/*
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">Converts a given binary string to a INTeger value
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">e.g. 11 =&gt; 3
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">SELECT  [dbo].[udf_binarytoINT]('1011011011110') -- 5854
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">SELECT [dbo].[udf_binarytoINT]('1111100111101111111') --511871
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">*/</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=CREATE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">CREATE</a> <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FUNCTION&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FUNCTION</a>  [dbo].[UDF_BinarytoInt](@binarystring <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=NVARCHAR&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">NVARCHAR</a>(100))
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=RETURNS&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">RETURNS</a> <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INT</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AS&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AS</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=BEGIN&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">BEGIN</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=DECLARE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">DECLARE</a> @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INT</a>, @rev <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=NVARCHAR&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">NVARCHAR</a>(100), @intvalue <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INT</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><span style="color:#008000;">-- Initialize the variables.</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SET&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SET</a> @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> = 1
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SET&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SET</a> @rev = REVERSE(@binarystring)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=DECLARE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">DECLARE</a>  @tbl <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=table&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">table</a> (powerv <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INT</a>, bitvalue <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=NVARCHAR&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">NVARCHAR</a>(1))
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><span style="color:#008000;">--Split the individual bits (0/1) into seperate rows </span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHILE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHILE</a> @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> &lt;= len(@rev)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">   <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=BEGIN&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">BEGIN</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">		<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INSERT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INSERT</a> <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=INTO&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">INTO</a> @tbl(powerv, bitvalue)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">		<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> -1, <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SUBSTRING&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SUBSTRING</a>(@rev, @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a>, 1)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">	    <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SET&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SET</a> @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> = @<a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=position&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">position</a> + 1
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;">   <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=END&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">END</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> @intvalue = <a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=sum&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">sum</a>(power(2, powerv) * bitvalue)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> @tbl
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> bitvalue &gt; 0
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=RETURN&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">RETURN</a> @intvalue
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=END&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">END</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"><a style="color:#0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=GO&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">GO</a>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#039;background-color:#fbfbfb;margin:0;"></pre>
</pre>
<p>Until then, happy coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=116&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2010/10/23/how-to-sql-convert-binary-string-to-integer-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Attributes, Properties and ViewState</title>
		<link>http://kalpeshshirodker.wordpress.com/2010/10/13/attributes-properties-and-viewstate/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2010/10/13/attributes-properties-and-viewstate/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 12:18:59 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">https://kalpeshshirodker.wordpress.com/2010/10/13/attributes-properties-and-viewstate/</guid>
		<description><![CDATA[Recently i was thinking on a rather a small but a niggling problem, as part of web control development, we save the information we need to be persisted in viewstate(this is rather obvious to state). The way i do it is as follows 1: public string ViewStatePropertyName 2: { 3: get 4: { 5: //this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=107&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently i was thinking on a rather a small but a niggling problem, as part of web control development, we save the information we need to be persisted in viewstate(this is rather obvious to state). The way i do it is as follows</p>
</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">string</span> ViewStatePropertyName</pre>
<pre><span class="lnum">   2:  </span>        {</pre>
<pre class="alt"><span class="lnum">   3:  </span>            get</pre>
<pre><span class="lnum">   4:  </span>            {</pre>
<pre class="alt"><span class="lnum">   5:  </span>                <span class="rem">//this is rather simplified version; we need to check null objects as well</span></pre>
<pre><span class="lnum">   6:  </span>                <span class="kwrd">return</span> (<span class="kwrd">string</span>)ViewState[<span class="str">&quot;ViewStatePropertyName&quot;</span>];</pre>
<pre class="alt"><span class="lnum">   7:  </span>            }</pre>
<pre><span class="lnum">   8:  </span>            set</pre>
<pre class="alt"><span class="lnum">   9:  </span>            {</pre>
<pre><span class="lnum">  10:  </span>                ViewState[<span class="str">&quot;ViewStatePropertyName&quot;</span>] = <span class="kwrd">value</span>;</pre>
<pre class="alt"><span class="lnum">  11:  </span>            }</pre>
<pre><span class="lnum">  12:  </span>        }</pre>
</div>
<p>This works fine, but takes up a lot of space. So i was thinking on the lines of using the power of Attributes (<a href="http://msdn.microsoft.com/en-us/library/aa288454%28VS.71%29.aspx" target="_blank">MSDN : Attributes Tutorial</a>). As i was wandering around i stumbled upon this article, which does pretty much the same thing what i wanted. Here is the link : <a href="http://helephant.com/2008/08/saving-server-control-properties-to-viewstate-with-custom-attributes/" target="_blank">Saving server control properties to ViewState with custom attributes</a>.</p>
<p>&#160;</p>
<p>I havent tried the example, will take a look once i have some little free space on my hand. Until then Happy Coding.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=107&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2010/10/13/attributes-properties-and-viewstate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert String Value to Valid DataType using Type Converters</title>
		<link>http://kalpeshshirodker.wordpress.com/2010/03/19/convert-string-value-to-valid-datatype/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2010/03/19/convert-string-value-to-valid-datatype/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 10:48:27 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://kalpeshshirodker.wordpress.com/2010/03/19/convert-string-value-to-valid-datatype/</guid>
		<description><![CDATA[While working on one of my projects which entitled creation of user control in ASP.Net, i was flummoxed with a very interesting problem. The problem was very simple and no doubt there was a straight forward answer to it, but i was not satisfied. The problem is for initializing properties for control dynamically. The user [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=97&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While working on one of my projects which entitled creation of user control in ASP.Net, i was flummoxed with a very interesting problem. The problem was very simple and no doubt there was a straight forward answer to it, but i was not satisfied. The problem is for initializing properties for control dynamically. </p>
<p>The user control is generic, but there is a fixed set of properties which are requierd for a certain behaviour. Values for each property for a given behaviour is stored in an XML config file. The user control will have a unique identifier which will point to the correct configuration.</p>
<p>Lets dive into the problem space.</p>
<p>Say there is a user control which has different types of properties exposed. The properties themselves are of different data types (for e.g. int, boolean, string, string array, enums. Pretty complex control, I know <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but this is a grind you need to go make things generic). For illustration let us assume a realistic scenario, where this kind of complex situation may arise (there are very few of them though <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>For illustration we shall assume a very simple scenario. We shall develop a user control for drawing a shape (2-Dimensional)</p>
<p>The shape control will have the following properties</p>
<ul>
<li>Type
<ul>
<li>Enum type </li>
<li>Type of shape (Circle, rectangle, polygon etc) </li>
</ul>
</li>
<li>No of Sides
<ul>
<li>Integer </li>
<li>in case of polygon type </li>
</ul>
</li>
<li>Length of each side
<ul>
<li>Array of strings (comma seperated string values) </li>
<li>in case of polygon type </li>
</ul>
</li>
<li>Scale
<ul>
<li>Enum type </li>
<li>The type of mathematical scale to use for lengths(Centimeter, Millimeter, Inches, meters) </li>
</ul>
</li>
<li>some more properties </li>
</ul>
<p>To initialize the properties of this control in the consuming aspx/ascx we would usually do something as suggested below</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:82px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#c71585;">Aryan</span>:<span style="color:#800000;">Shape</span> <span style="color:#ff0000;">runat</span>=<span style="color:#0000ff;">&quot;server&quot;</span> <span style="color:#ff0000;">Type</span>=<span style="color:#0000ff;">&quot;Polygon&quot;</span> <span style="color:#ff0000;">Sides</span>=<span style="color:#0000ff;">&quot;5&quot;</span> <span style="color:#ff0000;">Length</span>=<span style="color:#0000ff;">&quot;20,45,45,60,50&quot;</span> <span style="color:#ff0000;">Scale</span>=<span style="color:#0000ff;">&quot;Centimeter&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#c71585;">Aryan</span>:<span style="color:#800000;">Shape</span><span style="color:#0000ff;">&gt;</span></pre>
</pre>
<p>We wont go into details of how the properties are implemented, for our little pertains to initializing the properties dynamically.</p>
<p>The XML configuration snippet looks like below (for instance Shape type &#8211; Square)</p>
<p>So now if we wanted to refer to the configuration file to read th</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:287px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Shapes</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">  <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Shape</span> <span style="color:#ff0000;">ID</span>=<span style="color:#0000ff;">&quot;Square&quot;</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Property</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&quot;Type&quot;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&quot;Polygon&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Property</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Property</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&quot;Sides&quot;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&quot;4&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Property</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Property</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&quot;Length&quot;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&quot;20,20,20,20&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Property</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Property</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&quot;Scale&quot;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&quot;Inches&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Property</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">  <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Shape</span><span style="color:#0000ff;">&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Shapes</span><span style="color:#0000ff;">&gt;</span></pre>
</pre>
<p>e property values, we would do something like this</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:49px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#c71585;">Aryan</span>:<span style="color:#800000;">Shape</span> <span style="color:#ff0000;">runat</span>=<span style="color:#0000ff;">&quot;server&quot;</span> <span style="color:#ff0000;">ShapeConfigID</span>=<span style="color:#0000ff;">&quot;Square&quot;</span><span style="color:#0000ff;">&gt;</span><span style="color:#0000ff;">&lt;/</span><span style="color:#c71585;">Aryan</span>:<span style="color:#800000;">Shape</span><span style="color:#0000ff;">&gt;</span></pre>
</pre>
<p>Makes my consuming page less cluttered and i can reuse my configuration across multiple pages, effectively allowing to centralize my changes. sweet <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>How the values are initialized is what we are concerned and the crux of the post.</p>
<p>For initializing the values we need to do the following </p>
<ul>
<li>Read xml </li>
<li>Read property value </li>
<li>Assuming property value exists cast the property value to appropriate datatype and assign the value. </li>
</ul>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:264px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// &lt;summary&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// Reads the configuration information for the given shape and returns the value</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// for the property provided by PropertyName</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// &lt;/summary&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// &lt;param name=&quot;PropertyName&quot;&gt;Name of the property whose value need to be read&lt;/param&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// &lt;returns&gt;&lt;/returns&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">private</span> String GetPropertyValue(String PropertyName)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">{
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//read the xml file or the xml segment</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//assuming we have the proper xml segment</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//get to the property node suggested by property name</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//XPath = &quot;//Shape/Propert[@Name='&lt;PropertyName&gt;']&quot;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//read the node and return value</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">}</pre>
</pre>
<p>The function is pretty simple and i wont go into details of the implementation <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:195px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">string</span> sides = GetPropertyValue(&quot;<span style="color:#8b0000;">Sides</span>&quot;);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#0000ff;">int</span> intsides = -1;
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">Int32.TryParse(sides, <span style="color:#0000ff;">out</span> intsides);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#008000;">//set the property </span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">shp.sides = intsides;</pre>
</pre>
<p>The steps repeats for the other properties, based on the datatype the code changes. If the number of properties increase you can imagine the horror of the situation.</p>
<p>This type of code gives me the chills in any case, something needs to be done. I wanted something elegant. </p>
<p>This is how i did it, may be it is not the most fullproof, but it works and it reduces the lines of code i would otherwise have to write. I stumbled upon the solution during one of my rendezvous on the net. The solution uses <a title="Generics" href="http://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx" target="_blank">Generics</a> and another concept <a title="TypeConverters" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter.aspx" target="_blank">TypeConverters</a>. </p>
<p>There are whole lot of type converters defined which reads a string value and tries to convert the value to the appropriate datatype. There are whole lot of methods provided in the typeconverter class, which can be used, the one which i use is <a title="ConvertFromInvariantString" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter.convertfrominvariantstring(v=VS.90).aspx" target="_blank">ConvertFromInvariantString</a> method, which takes string as an argument and tries to convert it into the appropriate datatype. Here is the method</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:671px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// &lt;summary&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// Convert the string value to the appropriate datatype suggested by T</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// &lt;/summary&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#808080;">/// &lt;param name=&quot;dataValueString&quot;&gt;&lt;/param&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#808080;">/// &lt;returns&gt;&lt;/returns&gt;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"><span style="color:#0000ff;">public</span> T GetDatafromString&lt;T&gt;(<span style="color:#0000ff;">string</span> dataValueString)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">{
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//Initialize the value to return a default value</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    T returnValue = <span style="color:#0000ff;">default</span>(T);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//Get the Type for the return datatype; the Type will be used to get the appropriate converter</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    Type valueType = <span style="color:#0000ff;">typeof</span>(T);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//Get the converter for the given datatype</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    TypeConverter converter = TypeDescriptor.GetConverter(valueType);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//Convert the string to the appropriate data type value;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//the value returned will be a an object which needs to be cast to the required datatype</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    returnValue = (T)converter.ConvertFromInvariantString(dataValueString);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#0000ff;">return</span> returnValue;
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">}</pre>
</pre>
<p>Inorder to return the appropriate value for a given datatype with the value returned from XML file, the method below will do the bulk of the work </p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:470px;border-bottom:#cecece 1px solid;height:379px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"><span style="color:#0000ff;">private</span> T GetPropertyValue&lt;T&gt;(String PropertyName)
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">{
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//read the xml file or the xml segment</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//assuming we have the proper xml segment</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//get to the property node suggested by property name</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#008000;">//XPath = &quot;//Shape/Propert[@Name='&lt;PropertyName&gt;']&quot;</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">    <span style="color:#008000;">//read the node</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;"></pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;"> <span style="color:#008000;">//if the node contains value get the value</span>
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">    <span style="color:#0000ff;">return</span> GetDatafromString&lt;T&gt;(dataValueString);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">}</pre>
</pre>
<p>Now inorder to initialize the properties of the control, all we need to do is this</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:470px;border-bottom:#cecece 1px solid;height:126px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">...
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#ffffff;margin:0;">shp.sides = GetDataFromString&lt;<span style="color:#0000ff;">int</span>&gt;(&quot;<span style="color:#8b0000;">Sides</span>&quot;);
</pre>
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">...</pre>
</pre>
<p>It even works for enum types, so i no longer need to cast the enum to the appropriate enumtype, so this code will also work as a charm.</p>
<pre style="border-right:#cecece 1px solid;border-top:#cecece 1px solid;min-height:40px;overflow:auto;border-left:#cecece 1px solid;width:469px;border-bottom:#cecece 1px solid;height:62px;background-color:#fbfbfb;padding:5px;">
<pre style="font-size:12px;width:100%;font-family:consolas,&#39;background-color:#fbfbfb;margin:0;">shp.Type = GetPropertyValue&lt;Shape&gt;(&quot;<span style="color:#8b0000;">Shape</span>&quot;);</pre>
</pre>
<p>Sweet i say, very sweet.</p>
<p>With little ingenuity you can make it work for string array as well, we shall keep this as an exercise for you guys <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&#160;</p>
<p>Refrences</p>
<p><a title="MSDN : TypeConverter Class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter.aspx" target="_blank">MSDN : TypeConverter Class</a></p>
<p><a title="MSDN : An introduction to Generics" href="http://msdn.microsoft.com/en-us/library/ms379564(VS.80).aspx" target="_blank">MSDN : An introduction to Generics</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=97&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2010/03/19/convert-string-value-to-valid-datatype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting the absolute path in ASP.NET which is application independent</title>
		<link>http://kalpeshshirodker.wordpress.com/2009/10/05/getting-the-absolute-path-in-asp-net-which-is-application-independent/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2009/10/05/getting-the-absolute-path-in-asp-net-which-is-application-independent/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 11:37:49 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Dot Net]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://kalpeshshirodker.wordpress.com/2009/10/05/getting-the-absolute-path-in-asp-net-which-is-application-independent/</guid>
		<description><![CDATA[There comes a time when you need to get the absolute path to reference a file or some resource existing at some relative path of the website or web application. As things turned i was in need some of the similar functionality. The first thing that came to my mind was doing something similar : [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=95&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There comes a time when you need to get the absolute path to reference a file or some resource existing at some relative path of the website or web application. As things turned i was in need some of the similar functionality. The first thing that came to my mind was doing something similar :</p>
<p>&#160;</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0ef1f6db-8ebd-46ec-bced-7350501c3f9b" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#008000;">//</span><span style="color:#008000;">get the absolute path for the following relative path</span><span style="color:#008000;">
</span><span style="color:#000000;">String relPath </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">@"</span><span style="color:#800000;">~/ImageResource/ImageName.jpg</span><span style="color:#800000;">"</span><span style="color:#000000;">;
Control cntrl </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> Control();
String absPath </span><span style="color:#000000;">=</span><span style="color:#000000;"> cntrl.ResolveClientUrl(relPath);</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As it is this works great, but i wanted something more elegant, which doesnt involve the creation of the Control object. So i searched for sometime and stumbled upon an unknown utility function available, right over in .NET framework. Interesting to know that there so many useful functionality in-built in .NET framework which rarely are seen in practice. </p>
<p>Ok then about this utility API is called VirtualPathUtility and it is contained in the System.Web namespace. So using the VirtualUtilityPath you can rewrite the above piece of code as follows </p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8d72dcf1-813c-4ddb-8d68-af20c55a3d5f" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#000000;"> </span><span style="color:#008000;">//</span><span style="color:#008000;">get the absolute path for the following relative path</span><span style="color:#008000;">
</span><span style="color:#000000;">String relPath </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">@"</span><span style="color:#800000;">~/ImageResource/ImageName.jpg</span><span style="color:#800000;">"</span><span style="color:#000000;">;
String absPath </span><span style="color:#000000;">=</span><span style="color:#000000;">VirtualPathUtility.ToAbsolute(relPath);</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>Nice little function. But beware there are some pitfalls you need to avoid. This function is not one size fits all solution. You need to be aware of some of shortfalls described in some of the posts below. But for simple use, this works great.</p>
<p>&#160;</p>
<table cellspacing="0" cellpadding="2" width="459" border="0">
<tbody>
<tr>
<td valign="top" width="457"><strong>Related Posts</strong></td>
</tr>
<tr>
<td valign="top" width="457"><a title="MSDN: VirtualPathUtility Class" href="http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx" target="_blank">MSDN: VirtualPathUtility Class</a></td>
</tr>
<tr>
<td valign="top" width="457"><a title="Weblogs.asp.net: VirtualPathUtility Class" href="http://weblogs.asp.net/dwahlin/archive/2006/03/30/441555.aspx" target="_blank">Weblogs.asp.net: VirtualPathUtility Class</a></td>
</tr>
<tr>
<td valign="top" width="457"><a title="How VirtualPathUtility combines paths in .Net 2.0 - level 100" href="http://codebetter.com/blogs/jeffrey.palermo/archive/2006/03/10/140621.aspx" target="_blank">How VirtualPathUtility combines paths in .Net 2.0 &#8211; level 100</a></td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=95&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2009/10/05/getting-the-absolute-path-in-asp-net-which-is-application-independent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
		<item>
		<title>How-To : Splitting delimited strings using XQuery in SQL</title>
		<link>http://kalpeshshirodker.wordpress.com/2009/09/25/splitting-delimited-strings-using-xquery/</link>
		<comments>http://kalpeshshirodker.wordpress.com/2009/09/25/splitting-delimited-strings-using-xquery/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 04:10:54 +0000</pubDate>
		<dc:creator>kalpeshshirodker</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://kalpeshshirodker.wordpress.com/2009/09/25/splitting-delimited-strings-using-xquery/</guid>
		<description><![CDATA[Well, this was just kind of an experiment of sorts of using XQuery. The idea just occured some time back when i was trying some other similar experiment. Now as you all know there is no in-built function for Split in SQL. So lots of people have come out with different solution. This solution is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=91&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, this was just kind of an experiment of sorts of using XQuery. The idea just occured some time back when i was trying some other similar experiment. </p>
<p>Now as you all know there is no in-built function for Split in SQL. So lots of people have come out with different solution. This solution is just another solution to the old problem of splitting delimited strings. </p>
<p>The solutions i found mostly revolved around string manipulation, and i have been using the same before my chance encounter with XML support in SQL. The solution i came out with was using XQuery support in SQL Server and it works pretty well too. My thoughts are, it might be just a little wee faster than the other implementation (no numbers from me on that front <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<h3>Implementation</h3>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3508b104-7dd5-4a92-ab44-2097df121f09" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:auto;"><span style="color:#0000FF;">DECLARE</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#0000FF;">NVARCHAR</span><span style="color:#000000;">(</span><span style="color:#800000;font-weight:bold;">500</span><span style="color:#000000;">)
</span><span style="color:#0000FF;">DECLARE</span><span style="color:#000000;"> </span><span style="color:#008000;">@Delimiter</span><span style="color:#000000;"> </span><span style="color:#0000FF;">NVARCHAR</span><span style="color:#000000;">(</span><span style="color:#800000;font-weight:bold;">10</span><span style="color:#000000;">)
</span><span style="color:#0000FF;">DECLARE</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedStringXML</span><span style="color:#000000;"> XML

</span><span style="color:#0000FF;">SET</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">Apples,Bananas,Mangoes,Peaches,Watermelons</span><span style="color:#FF0000;">'</span><span style="color:#000000;">

</span><span style="color:#0000FF;">SET</span><span style="color:#000000;"> </span><span style="color:#008000;">@Delimiter</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">,</span><span style="color:#FF0000;">'</span><span style="color:#000000;">

</span><span style="color:#008080;">--</span><span style="color:#008080;">Create a document fragment for the delimited string</span><span style="color:#008080;">
</span><span style="color:#0000FF;">SET</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">REPLACE</span><span style="color:#000000;">(</span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">&lt;s&gt;</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">&lt;/s&gt;</span><span style="color:#FF0000;">'</span><span style="color:#000000;">,</span><span style="color:#008000;">@Delimiter</span><span style="color:#000000;">, </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">&lt;/s&gt;&lt;s&gt;</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> )
</span><span style="color:#0000FF;">PRINT</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#008080;">--</span><span style="color:#008080;">PRINTS &lt;s&gt;Apples&lt;/s&gt;&lt;s&gt;Bananas&lt;/s&gt;&lt;s&gt;Mangoes&lt;/s&gt;&lt;s&gt;Peaches&lt;/s&gt;&lt;s&gt;Watermelons&lt;/s&gt;</span><span style="color:#008080;">
</span><span style="color:#000000;">
</span><span style="color:#008080;">--</span><span style="color:#008080;">Cast the string to xml format, for use in the xquery</span><span style="color:#008080;">
</span><span style="color:#0000FF;">SET</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedStringXML</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">CAST</span><span style="color:#000000;">(</span><span style="color:#008000;">@DelimitedString</span><span style="color:#000000;"> </span><span style="color:#0000FF;">AS</span><span style="color:#000000;"> XML)

</span><span style="color:#0000FF;">SELECT</span><span style="color:#000000;"> t.r.query(</span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">./text()</span><span style="color:#FF0000;">'</span><span style="color:#000000;">)
</span><span style="color:#0000FF;">FROM</span><span style="color:#000000;"> </span><span style="color:#008000;">@DelimitedStringXML</span><span style="color:#000000;">.nodes(</span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">/s</span><span style="color:#FF0000;">'</span><span style="color:#000000;">) t(r)</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>For people who are unfamiliar with Xquery can check out the reference section.</p>
<p>Have fun and happy coding</p>
<h3>Reference</h3>
<p><a title="MSDN :: Introduction to XQuery in SQL Server 2005" href="http://msdn.microsoft.com/en-us/library/ms345122(SQL.90).aspx" target="_blank">MSDN :: Introduction to XQuery in SQL Server 2005</a></p>
<p><a title="MSDN Blogs :: XQuery Inside SQL Server 2005" href="http://blogs.msdn.com/mrorke/" target="_blank">MSDN Blogs :: XQuery Inside SQL Server 2005</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kalpeshshirodker.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kalpeshshirodker.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kalpeshshirodker.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kalpeshshirodker.wordpress.com&amp;blog=675108&amp;post=91&amp;subd=kalpeshshirodker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kalpeshshirodker.wordpress.com/2009/09/25/splitting-delimited-strings-using-xquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf0e9a8b13c5fa268cd3faa5d1d913ec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kalpeshshirodker</media:title>
		</media:content>
	</item>
	</channel>
</rss>
