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

<channel>
	<title>samurai joe</title>
	<atom:link href="http://www.samurai-joe.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.samurai-joe.com</link>
	<description>{coding warrior}</description>
	<lastBuildDate>Thu, 15 Oct 2009 21:33:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mosso Url Rewriting ASP.NET</title>
		<link>http://www.samurai-joe.com/./mosso-url-rewriting-aspnet/</link>
		<comments>http://www.samurai-joe.com/./mosso-url-rewriting-aspnet/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 16:31:00 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Mosso]]></category>
		<category><![CDATA[URL Rewriting]]></category>

		<guid isPermaLink="false">http://samurai-joe.com/?p=62</guid>
		<description><![CDATA[Just yesterday, I uploaded an application that I had created to Mosso. Some effort had gone into cleaning up the URL&#8217;s so that they would be search engine friendly. Cleaning the URL&#8217;s up also allowed the site to work effectively with or without AJAX enabled.
The module that I decided to use was urlrewriter.net (this was [...]]]></description>
			<content:encoded><![CDATA[<p>Just yesterday, I uploaded an application that I had created to Mosso. Some effort had gone into cleaning up the URL&#8217;s so that they would be search engine friendly. Cleaning the URL&#8217;s up also allowed the site to work effectively with or without AJAX enabled.<br />
The module that I decided to use was <a title="urlrewriter.net" href="http://urlrewriter.net/" target="_blank">urlrewriter.net</a> (this was not by choice. I would have liked to have been able to use the new IIS 7 module recently released, but that would have meant Mosso would have put it up on their servers. No, that would be too simple to do!). It is simple, clean and easy to understand. I followed the instructions provided by ScottGu on his post <a title="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" target="_blank">here</a> under approach 3. Nice and simple. Well so I thought&#8230;</p>
<p>I tested out my application on my localhost using Vista and all was running smoothly. Next I uploaded it to Mosso, and surprise surprise, I get a 404 Not Found when I try and access one of my clean url&#8217;s.</p>
<p>So I double checked to make sure that I had not done anything wrong. Nope, all was well and all paths were easy to understand and I didn&#8217;t do any fancy RegExp that could be throwing things off. So I looked on Google to see if anyone else had come accross the same problem. Well to my surprise, with all amounts of keywords, I didn&#8217;t find anyone who had written the answer for me (I am sure that after I post this that I will find one).</p>
<p>So, I figured, I should go to Mosso and explain to them that the example that they had provided (because they have yet to implement the IIS 7 module) via ScottGu&#8217;s website was not working on their servers. After over an hour online with their support I was still no closer to an answer. So they passed it on to their &#8220;admin&#8221; to try and resolve the problem. The next morning, the problem had indeed been resolved.</p>
<p>Their response via email was:</p>
<blockquote><p>It looks like the application pool needed to be set to integrated.<br />
Please let us know if you are still experiencing trouble. Have a great day!</p></blockquote>
<p>Well, that is clearly something that was not possible via their management interface. So for anyone experiencing this problem, it is not you, it is them. Simply ask support to fix up the damn application pool and you will be on your way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./mosso-url-rewriting-aspnet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Observer Pattern</title>
		<link>http://www.samurai-joe.com/./observer-pattern/</link>
		<comments>http://www.samurai-joe.com/./observer-pattern/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 19:20:46 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Observer Pattern]]></category>

		<guid isPermaLink="false">http://samurai-joe.com/index.php/2008/10/11/observer-pattern/</guid>
		<description><![CDATA[A simple overview of the Observer Design Pattern using C#.]]></description>
			<content:encoded><![CDATA[<p>I have recently been studying design patterns in the hope to improve my code not only from a readability standpoint but from a functional perspective as well. I figured the best way to learn something properly is to write about it. So here I go on the Observer Pattern. </p>
<p>I found a simple yet concise definition on <a href="http://www.dofactory.com/Patterns/PatternObserver.aspx" target="_blank">data &amp; object factory</a>:</p>
<blockquote><p>Define a one-to-many dependency between objects so that when one object changes state, all its dependants are notified an updated automatically. <a href="http://www.dofactory.com/Patterns/PatternObserver.aspx" target="_blank">[link]</a></p>
</blockquote>
<p>I then took this and thought it was best to come up with an analogy to remember this by more simply. So here I go (Maybe it won&#8217;t work, or maybe you have a simpler idea. Please let me know):</p>
<blockquote><p>Twitter is a good example of this pattern. When you follow someone you are a dependant on that person (and visa versa when someone is following you). When the person being followed updates their status, feed, micro-blog (or whatever name they have for it), then all dependants, ie: those who are following, are also notified of the update and have the opportunity to react to it. </p>
</blockquote>
<p>That was as simple as I can get. Basic principle found in every day life really. We could also liken it to a blog that updates its subscribers. From that we need to delve into the parts of the pattern to understand it and write code around the pattern. There are only a few things that need to be remembered.</p>
<ul>
<li>Subject (the person being followed).</li>
<li>Observer (the person following).</li>
</ul>
<p>As with everything in programming we try and abstract away as much as possible to understand it better and to improve reuse. So there are going to be interfaces and abstract classes in this pattern when used properly (IMHO). Lets start by creating a simple Subject Class which contains a List or ArrayList of Observers.</p>
<p><strong><u>Subject Class</u></strong></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> Subject {</pre>
<pre><span class="lnum">   2:  </span>   List&lt;IObserver&gt; observers { get; set; }</pre>
<pre class="alt"><span class="lnum">   3:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>This looks a bit bare. Lets flesh it out with the next step. The logical thing is to realise that once we make a tweet we want to be able to <strong>notify</strong> the follower that we have updated our status. Ok, that&#8217;s fine, but there are two other things that we might want to do. We might want to let someone else follow us (<strong>attach</strong>), or we might want to block someone who is already following us (<strong>detach</strong>). So we need to add some code to show that is possible.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Attach() { }</pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Detach() { }</pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Notify() { }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Super easy. Now we just need to add some simple code to these methods to make them do something. </p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> Subject {</pre>
<pre><span class="lnum">   2:  </span>        List&lt;IObserver&gt; observers { get; set; }</pre>
<pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> Subject() {</pre>
<pre><span class="lnum">   4:  </span>            observers = <span class="kwrd">new</span> List&lt;IObserver&gt;();</pre>
<pre class="alt"><span class="lnum">   5:  </span>        }</pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Attach(IObserver observer) {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            observers.Add(observer);</pre>
<pre><span class="lnum">   8:  </span>        }</pre>
<pre class="alt"><span class="lnum">   9:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Detach(IObserver observer) {</pre>
<pre><span class="lnum">  10:  </span>            observers.Remove(observer);</pre>
<pre class="alt"><span class="lnum">  11:  </span>        }</pre>
<pre><span class="lnum">  12:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Notify() { </pre>
<pre class="alt"><span class="lnum">  13:  </span>            <span class="kwrd">foreach</span>(IObserver observer <span class="kwrd">in</span> observers){</pre>
<pre><span class="lnum">  14:  </span>                observer.Update();</pre>
<pre class="alt"><span class="lnum">  15:  </span>            }</pre>
<pre><span class="lnum">  16:  </span>        }</pre>
<pre class="alt"><span class="lnum">  17:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>One thing that I am forgetting is the IObserver interface. It is completely simple and contains one method:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">interface</span> IObserver {</pre>
<pre><span class="lnum">   2:  </span>   <span class="kwrd">void</span> Update();</pre>
<pre class="alt"><span class="lnum">   3:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Well, now that we have our abstract Subject class and our IObserver interface we are ready to implement the pattern into something a little more concrete. So let&#8217;s go ahead and do that now. Let&#8217;s create a simple Concrete Subject class:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> OurSubject&lt;T&gt; : Subject {</pre>
<pre><span class="lnum">   2:  </span>   <span class="kwrd">public</span> T SubjectState { get; set; }</pre>
<pre class="alt"><span class="lnum">   3:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>That is as simple as I can find. Then we move onto implementing the IObserver interface. Lets work with that:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> OurObserver&lt;T&gt; : IObserver {</pre>
<pre><span class="lnum">   2:  </span>        <span class="kwrd">public</span> OurSubject&lt;T&gt; Subject { get; set; }</pre>
<pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> T _observerState;</pre>
<pre><span class="lnum">   4:  </span>&#160;</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> OurObserver(OurSubject&lt;T&gt; subject){</pre>
<pre><span class="lnum">   6:  </span>            Subject = subject;</pre>
<pre class="alt"><span class="lnum">   7:  </span>        }</pre>
<pre><span class="lnum">   8:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Update() {</pre>
<pre class="alt"><span class="lnum">   9:  </span>            _observerState = Subject.SubjectState;</pre>
<pre><span class="lnum">  10:  </span>        }</pre>
<pre class="alt"><span class="lnum">  11:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>So really all that is happening there is the OurObserver is being updated every time that OurSubject changes state. Lets run the below code (with a small mod) and see what we can see:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>OurSubject&lt;<span class="kwrd">string</span>&gt; subject = <span class="kwrd">new</span> OurSubject&lt;<span class="kwrd">string</span>&gt;();</pre>
<pre><span class="lnum">   2:  </span>subject.Attach(<span class="kwrd">new</span> OurObserver&lt;<span class="kwrd">string</span>&gt;(subject));</pre>
<pre class="alt"><span class="lnum">   3:  </span>subject.Attach(<span class="kwrd">new</span> OurObserver&lt;<span class="kwrd">string</span>&gt;(subject));</pre>
<pre><span class="lnum">   4:  </span>subject.SubjectState = <span class="str">&quot;Changing state&quot;</span>;</pre>
<pre class="alt"><span class="lnum">   5:  </span>subject.Notify();</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Our output is as follows:</p>
<p><a href="http://samurai-joe.com/wp-content/uploads/2008/10/image1.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="41" alt="image" src="http://samurai-joe.com/wp-content/uploads/2008/10/image-thumb1.png" width="348" border="0" /></a> </p>
<p>Where the code at the end is the hashcode of the object. So we can see that it is clearly working right the way that we want it to.</p>
<p>Lets do something a little more along the lines of the analogy that we used before hand. Lets create a Twitterer (subject, poster) and a Twitteree (follower) and see what we can see. Using the abstract Subject class and the IObserver interface we can do the following (it is not very pretty and could be vastly improved):</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>   <span class="kwrd">public</span> <span class="kwrd">class</span> Twitterer : Subject {</pre>
<pre><span class="lnum">   2:  </span>        <span class="kwrd">private</span> <span class="kwrd">string</span> _currentTweet;</pre>
<pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> CurrentTweet {</pre>
<pre><span class="lnum">   4:  </span>            get { <span class="kwrd">return</span> _currentTweet; }</pre>
<pre class="alt"><span class="lnum">   5:  </span>            set { _currentTweet = <span class="kwrd">value</span>; Notify(); } </pre>
<pre><span class="lnum">   6:  </span>        }</pre>
<pre class="alt"><span class="lnum">   7:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Tweet(<span class="kwrd">string</span> tweet) {</pre>
<pre><span class="lnum">   8:  </span>            CurrentTweet = tweet;</pre>
<pre class="alt"><span class="lnum">   9:  </span>        }</pre>
<pre><span class="lnum">  10:  </span>    }</pre>
<pre class="alt"><span class="lnum">  11:  </span>&#160;</pre>
<pre><span class="lnum">  12:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> Twitteree : IObserver {</pre>
<pre class="alt"><span class="lnum">  13:  </span>        <span class="kwrd">public</span> Twitterer OurHero { get; set; }</pre>
<pre><span class="lnum">  14:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> myName { get; set; }</pre>
<pre class="alt"><span class="lnum">  15:  </span>        <span class="kwrd">public</span> Twitteree(<span class="kwrd">string</span> name) {</pre>
<pre><span class="lnum">  16:  </span>            <span class="kwrd">this</span>.myName = name;</pre>
<pre class="alt"><span class="lnum">  17:  </span>        }</pre>
<pre><span class="lnum">  18:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Update() {</pre>
<pre class="alt"><span class="lnum">  19:  </span>            Console.WriteLine(<span class="str">&quot;Twitteree {0} received a tweet&quot;</span>, <span class="kwrd">this</span>.myName);</pre>
<pre><span class="lnum">  20:  </span>        }</pre>
<pre class="alt"><span class="lnum">  21:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Then when we run it we get:</p>
<p><a href="http://samurai-joe.com/wp-content/uploads/2008/10/image2.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="54" alt="image" src="http://samurai-joe.com/wp-content/uploads/2008/10/image-thumb2.png" width="314" border="0" /></a> </p>
<p>This is the most basic of introductions that I can do and as my understanding increases of design patterns I am sure that more insightful posts will follow.</p>
<p>For reference purposes please see:</p>
<ul>
<li>&#160;<a href="http://www.dofactory.com/Patterns/PatternObserver.aspx" target="_blank">[link]</a>, <a href="http://wiki.asp.net/page.aspx/490/observer-pattern/" target="_blank">[link]</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./observer-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding an &quot;ALL&quot; to a LinqDataSource Dropdownlist</title>
		<link>http://www.samurai-joe.com/./adding-an-all-to-a-linqdatasource-dropdownlist/</link>
		<comments>http://www.samurai-joe.com/./adding-an-all-to-a-linqdatasource-dropdownlist/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 15:38:47 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LinqDataSource]]></category>

		<guid isPermaLink="false">http://samurai-joe.com/index.php/2008/10/11/adding-an-all-to-a-linqdatasource-dropdownlist/</guid>
		<description><![CDATA[Databainding a linqdatasource and dropdownlist, but adding an "ALL" to the list to increase search power.]]></description>
			<content:encoded><![CDATA[<p>Recently I went through the trouble of trying to get a LinqDataSource to bind an &quot;ALL&quot; into a dropdownlist. This was necessary because I was using my DropDownList to filter my GridView. I took the Categories table from the Northwind Database for my sample.</p>
<p>I found an easy way to do it and then by mistake I found an even more surprising easy way to do it. I shall start with the more legitimate way (at least the one that makes some sense to me).</p>
<p>First things first, add a LinqDataSource to your page and a simple DropDownList. Then bind the DropDownList to the LinqDataSource.&#160; Then add an event to the DataBound event of the DropDownList. Then simple add the following code:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">protected</span> <span class="kwrd">void</span> DropDownList1_DataBound(<span class="kwrd">object</span> sender, EventArgs e) {</pre>
<pre><span class="lnum">   2:  </span>   ((DropDownList)sender).Items.Insert(0, <span class="kwrd">new</span> ListItem(<span class="str">&quot;All&quot;</span>, <span class="str">&quot;-1&quot;</span>, <span class="kwrd">true</span>));</pre>
<pre class="alt"><span class="lnum">   3:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Then that will allow an item to be inserted into the first position within the list. This is not the entire problem. Because the DropDownList is being used as a filter for the GridView (which has a separate LinqDataSource in this example), we need to instruct the other LinqDataSource what to do with this new value &quot;-1&quot;. So in essence we need to tell it to remove the filter, because we now want all records back. So on the Selecting event of the LinqDataSource we need to remove the Where parameter that is being filtered. So, lets give an example:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">protected</span> <span class="kwrd">void</span> LinqDataSource2_Selecting(<span class="kwrd">object</span> sender, LinqDataSourceSelectEventArgs e) {</pre>
<pre><span class="lnum">   2:  </span>  <span class="kwrd">if</span> (DropDownList1.SelectedValue == <span class="str">&quot;-1&quot;</span>) {</pre>
<pre class="alt"><span class="lnum">   3:  </span>    e.WhereParameters.Remove(<span class="str">&quot;CategoryID&quot;</span>);</pre>
<pre><span class="lnum">   4:  </span>  }</pre>
<pre class="alt"><span class="lnum">   5:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>That&#8217;s all there is to it. Now onto the other method.</p>
<p><strong>Method Weird </strong></p>
<p>I experimented and wondered whether it would be possible to insert an empty &quot;ALL&quot; item into the returned result set before they were bound to the actual DropDownList. So this would need to be performed on the Selected event of the LinqDataSource bound to the DropDownList. It turns out that the LinqDataSourceStatutEventArgs has a propery called &quot;Result&quot; which contains the results of the selected query. Ah ha, I thought, lets put it there by adding two lines of code:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>List&lt;Item&gt; allItems = (List&lt;Item&gt;)e.Result;</pre>
<pre><span class="lnum">   2:  </span>allItems.Insert(0, (<span class="kwrd">new</span> Item() { ID = -1, ItemName = <span class="str">&quot;All&quot;</span> }));</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Or something to that effect. I ran the website and no luck, the new item added did not appear in the DropDownList. I thought, maybe there was something wrong with the way I had worked the code, but I couldn&#8217;t find any fault. Then by a happy mistake I added a DataBinding event to the DropDownList. Now, I thought I needed to put something in there, but I ran the code without anything in the DataBinding event and by miracle there was an All in the DropDownList.</p>
<p><a href="http://samurai-joe.com/wp-content/uploads/2008/10/image.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="48" alt="image" src="http://samurai-joe.com/wp-content/uploads/2008/10/image-thumb.png" width="111" border="0" /></a> </p>
<p>That is all there is to it. Hopefully this is helpful for someone. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./adding-an-all-to-a-linqdatasource-dropdownlist/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Warren Buffet on Gold</title>
		<link>http://www.samurai-joe.com/./warren-buffet-on-gold/</link>
		<comments>http://www.samurai-joe.com/./warren-buffet-on-gold/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 14:52:09 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://samurai-joe.com/index.php/2008/09/warren-buffet-on-gold/</guid>
		<description><![CDATA[I read an interesting quote over the weekend where the sage of Omaha, Warren Buffet, gives a thought provoking view on Gold. He says
It gets dug out of the ground in Africa, or someplace. Then we melt it down, dig another hole, bury it again and pay people to stand around guarding it. It has [...]]]></description>
			<content:encoded><![CDATA[<p>I read an interesting quote over the weekend where the sage of Omaha, Warren Buffet, gives a thought provoking view on Gold. He says</p>
<blockquote><p>It gets dug out of the ground in Africa, or someplace. Then we melt it down, dig another hole, bury it again and pay people to stand around guarding it. It has no utility. Anyone watching from Mars would be scratching their head.</p>
</blockquote>
<p>I thought this was an interesting view to take. All things considered, what he says makes total sense. I guess it all comes back to perceived value. The same goes with housing. I may value someone&#8217;s house 50% less than a real estate agent, but that is the value that it is equated in my mind. Subjective as it may be. But then we have to look at the collective perception of the majority of the population and Gold has a higher value than most other metals. As we can see with the price of Gold versus just 6 years ago. </p>
<p>Early man must have liked the shine!! What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./warren-buffet-on-gold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LinqDataSource, FormView DateTime Insert Errors</title>
		<link>http://www.samurai-joe.com/./linqdatasource-formview-datetime-insert-errors/</link>
		<comments>http://www.samurai-joe.com/./linqdatasource-formview-datetime-insert-errors/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 15:58:16 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[FormView]]></category>
		<category><![CDATA[LinqDataSource]]></category>

		<guid isPermaLink="false">http://samurai-joe.com/index.php/2008/09/linqdatasource-formview-datetime-insert-errors/</guid>
		<description><![CDATA[I have recently been using the LinqDataSource and the GridView control together to speed up my development time. On one project that I have I used the LinqDataSource in conjunction with the FormView control. It has been extremely useful, especially for updating data in a somewhat error free way. 
However, I have a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been using the LinqDataSource and the GridView control together to speed up my development time. On one project that I have I used the LinqDataSource in conjunction with the FormView control. It has been extremely useful, especially for updating data in a somewhat error free way. </p>
<p>However, I have a lot of Nullable DateTimes in my database and consequently in my LinqDataContext. When I leave say my DateCompleted field empty and then click update on the FormView control, I get the following error:</p>
<p><a href="http://samurai-joe.com/wp-content/uploads/2008/09/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="server error in application" src="http://samurai-joe.com/wp-content/uploads/2008/09/image-thumb.png" width="684" border="0" /></a> </p>
<p>Now this was a little bit of a problem for me. I thought there must be something wrong with my LinqDataContext. So I checked my database, sure enough, DateCompleted is nullable and within my LinqDataContext everything was fine. So what the hell!!</p>
<p>Quickly I looked into the capabilities of the LinqDataSource and found that update parameters are passed to the underlying LinqDataContext and it turns out that the values don&#8217;t just default to NULL when they are handed over. It is up to the individual programmer to set this up. So in order to succeed all you have to do is add the following:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>&lt;UpdateParameters&gt;</pre>
<pre><span class="lnum">   2:  </span>    &lt;asp:Parameter Name=<span class="str">&quot;DateCompleted&quot;</span> <strong>ConvertEmptyStringToNull=<span class="str">&quot;true&quot;</span></strong> /&gt;</pre>
<pre class="alt"><span class="lnum">   3:  </span>&lt;/UpdateParameters&gt;</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Within the UpdateParameters we need to insert a parameter that corresponds to the offending field (LinqDataContext name) and then set the<strong> ConvertEmptyStringToNull = true</strong>. Which need to be performed for all offending fields. Which seems like a pain in the bum (I thought they would have put it as a property of the LinqDataSource itself to allow you to default all fields to NULL if they are emtpy, but hey.. what do I know), and indeed is. But at the end of the day, you have achieved the end goal and no more errors. It will turn your empty string into a null and then everybody is happen. Such a simple thing. Hopefully this has been helpful for someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./linqdatasource-formview-datetime-insert-errors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Blog Switch Over</title>
		<link>http://www.samurai-joe.com/./blog-switch-over/</link>
		<comments>http://www.samurai-joe.com/./blog-switch-over/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 11:37:40 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://wordpress.samurai-joe.com/?p=34</guid>
		<description><![CDATA[Recently I have been neglecting my posting duties. I am not entirely sure why that is (probably because I feel I have nothing interesting to say), but alas that is probably for another post.
I helped a friend out with a transfer of their Wordpress blog across from one hosting environment to another and during the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been neglecting my posting duties. I am not entirely sure why that is (probably because I feel I have nothing interesting to say), but alas that is probably for another post.</p>
<p>I helped a friend out with a transfer of their Wordpress blog across from one hosting environment to another and during the process have come to really quite admire Wordpress for its simplicity and ease of use, setup, etc. After a quick message to my hosting support, they were able to get PHP working properly again and I was able to switch over to Wordpress.</p>
<p>A friend of mine recommended a theme to apply, <a href="http://blogsessive.com/blogging-tools/simple-balance-free-simple-wordpress-theme/">found here</a> (credit goes to Alex @ <a href="http://blogsessive.com">BLOGSESSIVE.COM</a> for a wonderfully clean and simple theme), and I was set to make the switch. Just modified the theme a little bit so that there is only one column to the side rather than two (I prefer the wider spacing to display code) and we have what we have.</p>
<p>I also imported my old posts (really quite old) from another blog that I started but did not keep up for whatever reason. It was when I was playing around with OpenSocial &amp; ASP.NET to get them working nice and simple (read below), but it turned out to be harder than I thought.</p>
<p>Anyway, the blog is up, then theme is nice and simple, clean, etc and I am ready to write some interesting posts!! If you have any suggestions, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./blog-switch-over/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Theme Up</title>
		<link>http://www.samurai-joe.com/./new-theme-up/</link>
		<comments>http://www.samurai-joe.com/./new-theme-up/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 11:03:54 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://wordpress.samurai-joe.com/?p=7</guid>
		<description><![CDATA[Well it took a while to find something that I was happy with, but I finally  did. But even though the theme is almost finished, I am still not entirely sure  that it is the theme that I want to go with. Oh well, at the end of the day, it  is [...]]]></description>
			<content:encoded><![CDATA[<p>Well it took a while to find something that I was happy with, but I finally  did. But even though the theme is almost finished, I am still not entirely sure  that it is the theme that I want to go with. Oh well, at the end of the day, it  is the content that matters the most I guess.</p>
<p>While surfing the web and looking for a new theme I came across a new blog  engine called <a href="http://www.habariproject.org/en/"><strong>habari</strong></a> which is  quite nice at this early stage. It also comes with a theme that I love (<a href="http://demo.habariproject.org/">link here</a>). I also found some other  themes (one that I based my theme off) that were particularly nice and simple <a href="http://habari.bcse.info/">here</a> &amp; <a href="http://fireyy.com/archives/simplus-theme-for-habari-175">here</a> (this  last one is particularly brilliant). There main reason behind the desire to move  to something else is nothing more than a desire for a more attractive theme. The  Blogengine.net theme library is something that I am not particularly happy with.  They are simple and clean enough, but they feel like they were not designed with  a creative flair. Whereas the other themes for habari that I previously  mentioned are clean, crisp and seem to have a designers touch, rather than a  developers touch, which I see as important for future proofing my blog. At the  end of the day useability of the most important perspective, but it is also nice  for the blog to actually look nice and stand out a little more.</p>
<p>However, because of my hosting provider I am not capable at this point in  time of hosting Habari on my shared hosting environment, which is a pain in the  buttocks for the simple reason that I have had to theme this up myself and adapt  it to blogengine.net. So there are many, many imperfections that will be ironed  out over the weeks. But, if my hosting provider actually decides to implement my  request and installed the mysql add in thing that is missing then I will be  using habari and will not have to worry about creating a theme</p>
<p>I am sure that in the next 6 months I will look at this blog and force myself  to look at something different and adopt that. It is simply the way that I work,  something that I might like 1 month, will most certainly be out of favour within  a short period of time and I will be forced by my own neurotic brain to change  what is already there and working perfectly well.</p>
<p>Anyway, if there are any suggestions for change on this blog, then please let  me know. I will be posting more important topics soon, once I get this  procrastination beast locked up for good (he is quite a ferocious monster  indeed).&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./new-theme-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSocial &amp; ASP.NET Part 3</title>
		<link>http://www.samurai-joe.com/./opensocial-and-aspnet-part-3/</link>
		<comments>http://www.samurai-joe.com/./opensocial-and-aspnet-part-3/#comments</comments>
		<pubDate>Tue, 27 May 2008 18:41:00 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[OpenSocial]]></category>
		<category><![CDATA[Social Networking]]></category>

		<guid isPermaLink="false">http://wordpress.samurai-joe.com/index.php/2008/05/opensocial-and-aspnet-part-3/</guid>
		<description><![CDATA[I was making a simple mistake when it came to

gadgets.util.registerOnLoadHandler()

I was ommitting placing the () at the end of the function to be called.
Anyway, now that that has been resolved, I have simply placed all the  config.init code from the previous post in the method that is called on gadget.util.registerOnLoadHandler.
This makes things a little [...]]]></description>
			<content:encoded><![CDATA[<p>I was making a simple mistake when it came to</p>
<blockquote>
<p><span style="font-weight: bold; font-style: italic;">gadgets.util.registerOnLoadHandler()</span></p>
</blockquote>
<p>I was ommitting placing the () at the end of the function to be called.<br />
Anyway, now that that has been resolved, I have simply placed all the  config.init code from the previous post in the method that is called on gadget.util.registerOnLoadHandler.<br />
This makes things a little easier.<br />
However, we are still in the situation where the application is being run within an IFrame. Therefore opensocial calls apparently become XSS and are blocked with the default settings. This is annoying.<br />
Settings the rights values for the initial load settings may be the key, however I have not been able to work it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./opensocial-and-aspnet-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSocial &amp; ASP.NET Part 2</title>
		<link>http://www.samurai-joe.com/./opensocial-and-aspnet-part-2/</link>
		<comments>http://www.samurai-joe.com/./opensocial-and-aspnet-part-2/#comments</comments>
		<pubDate>Wed, 21 May 2008 12:39:00 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Hi5]]></category>
		<category><![CDATA[OpenSocial]]></category>

		<guid isPermaLink="false">http://wordpress.samurai-joe.com/index.php/2008/05/opensocial-and-aspnet-part-2/</guid>
		<description><![CDATA[The saga continues&#8230;.
Unfortunately it appears that Opensocial and ASP.NET do go together somewhat, however there are a few hiccups along the way. One deals primary with the Opensocial API code that is generated by hi5. After my last post, I went through and tried to debug the errors that I had and that others had [...]]]></description>
			<content:encoded><![CDATA[<p>The saga continues&#8230;.<br />
Unfortunately it appears that Opensocial and ASP.NET do go together somewhat, however there are a few hiccups along the way. One deals primary with the Opensocial API code that is generated by hi5. After my last post, I went through and tried to debug the errors that I had and that others had found also.<br />
After a little while, I found the</p>
<blockquote>
<p><span style="font-weight: bold; font-style: italic;">gadgets.config.register</span></p>
</blockquote>
<p>being called at the bottom of the opensocial javascript include. Trying to step through this using Firebug &amp; Javascript Debugger, I came to the conclusion that after calling the function, the anonpmyous function that is included as a parameter is not being called. This caused some worries, because it is not something that can be easily fixed.<br />
I therefore promptly downloaded the javascript file and hardcoded it to be included rather than fetching it from the hi5 servers. After a lot of playing and modifying, looking for something to fix, I came up empty. So I decided to compare the javascript that was coming down using type=&quot;html&quot;.<br />
Well, it appeared that there was one extra line at the bottom of the javascript in type=&quot;html&quot;.</p>
<blockquote>
<pre class="csharpcode">

gadgets.config.init({&quot;rpc&quot;:{&quot;parentRelayUrl&quot;:&quot;/friend/apps/rpc_relay.html&quot;,
&quot;useLegacyProtocol&quot;:false},&quot;views&quot;:{&quot;preview&quot;:{&quot;isOnlyVisible&quot;:true,
&quot;aliases&quot;:[&quot;PREVIEW&quot;]},&quot;popup&quot;:{&quot;isOnlyVisible&quot;:true,&quot;aliases&quot;:[&quot;POPUP&quot;]},
&quot;canvas&quot;:{&quot;isOnlyVisible&quot;:true,&quot;aliases&quot;:[&quot;FULL_PAGE&quot;]},
&quot;profile&quot;:{&quot;isOnlyVisible&quot;:false,&quot;aliases&quot;:[&quot;DASHBOARD&quot;,&quot;default&quot;]}},
&quot;core.util&quot;:{&quot;dynamic-height&quot;:{},&quot;opensocial-0.7&quot;:{}},&quot;opensocial-0.7&quot;
:{&quot;path&quot;:&quot;/gadgets/socialdata&quot;,&quot;domain&quot;:&quot;hi5.com&quot;,&quot;supportedFields&quot;:
{&quot;person&quot;:[&quot;id&quot;,&quot;name&quot;,&quot;thumbnailUrl&quot;,&quot;profileUrl&quot;,&quot;gender&quot;,&quot;status&quot;,
&quot;presence&quot;],&quot;activity&quot;:[&quot;id&quot;,&quot;title&quot;]},&quot;enableCaja&quot;:true},&quot;core.io&quot;:
{&quot;jsonProxyUrl&quot;:&quot;proxy?output=js&quot;,&quot;proxyUrl&quot;:&quot;http://www.a.hi5modules.com/
gadgets/proxy?url=%url%&amp;refresh=%refresh%&quot;},&quot;skins&quot;:{&quot;properties&quot;:{
&quot;BG_POSITION&quot;:&quot;&quot;,&quot;FONT_COLOR&quot;:&quot;&quot;,&quot;BG_IMAGE&quot;:&quot;&quot;,&quot;BG_REPEAT&quot;:&quot;&quot;,
&quot;ANCHOR_COLOR&quot;:&quot;&quot;,&quot;BG_COLOR&quot;:&quot;&quot;}}});gadgets.Prefs.setMessages_({});</pre>
</blockquote>
<p>I don&#8217;t really know whether this will solve the problem forever, but I added this one line to my downloaded opensocial javascript.<br />
Ran the application and hey presto it seems that it is now working.<br />
At least, it is loading properly.<br />
I still can&#8217;t seem to work out what is going on with </p>
<blockquote>
<p><span style="font-weight: bold; font-style: italic;">gadgets.util.registerOnLoadHandler()</span></p>
</blockquote>
<p>but when stepping through the code, it calls it, it just does not call the function that is passed in for some reason!!<br />
However, putting any code in jQuery&#8217;s ready function works the treat (for simple things).</p>
<p>So I now have to contact hi5 and ask whether this is a deliberate removal of code or not? If so, why?</p>
<p>Unfortunately, this is not the end, there are still errors occuring, which I am still looking at. However, I will post again, once I have had a chat with Hi5.</p>
<p>Hope this helps people.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./opensocial-and-aspnet-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>OpenSocial &amp; ASP.NET Part 1</title>
		<link>http://www.samurai-joe.com/./opensocial-and-aspnet/</link>
		<comments>http://www.samurai-joe.com/./opensocial-and-aspnet/#comments</comments>
		<pubDate>Sun, 18 May 2008 14:34:00 +0000</pubDate>
		<dc:creator>samuraijoe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[OpenSocial]]></category>

		<guid isPermaLink="false">http://wordpress.samurai-joe.com/index.php/2008/05/opensocial-and-aspnet/</guid>
		<description><![CDATA[Being a c# ASP.NET developer, I wanted to develop an opensocial application that could be developed with server side code so that I could easily interact with my services that I have on my server and also so that I can more importantly interact with my database directly, without using the gadgets.io.makeRequest function made available.
It [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 85%;">Being a c# ASP.NET developer, I wanted to develop an opensocial application that could be developed with server side code so that I could easily interact with my services that I have on my server and also so that I can more importantly interact with my database directly, without using the gadgets.io.makeRequest function made available.</p>
<p>It is also important to me that I can develop using a clean separation of code, including CSS, JS, HTML, etc.</p>
<p>I am currently developing with the Hi5 framework because it offers simplicity and a wide variety of display languages (which I am interested in taking advantage of).</p>
<p>I used the following steps to get it working:<br />
</span></p>
<ul>
<li><span style="font-size: 85%;">Created a sample ASP.NET application and uploaded it to me server. This included some simple code to talk with my services and talk to the back end database.<br />
    </span></li>
<p>    <span style="font-size: 85%;"><br />
    </span></p>
<li><span style="font-size: 85%;">I then created a sample Opensocial gadget specification XML file. There are two type&#8217;s of content that can be specified. HTML &amp; URL. (<a href="http://code.google.com/apis/gadgets/docs/fundamentals.html#URL">http://code.google.com/apis/gadgets/docs/fundamentals.html#URL</a> for further reference).<br />
    </span></li>
<p>    <span style="font-size: 85%;"><br />
    </span></ul>
<blockquote>
<p><span style="font-size: 85%;">type=&quot;url&quot; href=&quot;http://fixedurl/default.aspx&quot;<br />
    </span></p>
</blockquote>
<p><span style="font-size: 85%;">The unfortunate part about the above is that (at least with Hi5), when you include the opensocial feature as a &quot;Require&quot;, it append the following to the url: </span></p>
<blockquote>
<p><span style="font-size: 85%;">&quot;?&amp;libs=/gadgets/js/opensocial-0.7.js?v=75eb5ef0c8cac834ca8d76b8ed3f7a7&amp;synd=hi5&amp;debug=0&quot;</span></p>
</blockquote>
<p><span style="font-size: 85%;">Now the unfortunate thing about this is, my server does not know what to do with the appended query string and therefore cannot go and load the Opensocial javascript API. Which, when called alerts with an &quot;opensocial is not defined&quot; in firebug.</p>
<p>    There is no simple way around this. After a bit of searching I found a way that works for the moment, although this is certainly not a final solution.<br />
    </span></p>
<ul>
<li><span style="font-size: 85%;">In the Page_Load section of the code, I simply put:</span></li>
</ul>
<blockquote>
<p><span style="font-size: 85%;">if (!String.IsNullOrEmpty(Request.QueryString[&quot;libs&quot;])) {<br />
    ClientScript.RegisterClientScriptInclude(&quot;libs&quot;, @&quot;http://www.a.hi5modules.com&quot; + Request.QueryString[&quot;libs&quot;]);<br />
    }</span></p>
</blockquote>
<p><span style="font-size: 85%;">This then allows the Opensocial library to be used. This is by no means perfect and is not the final answer.<br />
    If someone else has done this and could shed some more light on how to get it working without a hitch, then please let me know.</p>
<p>    The beauty of this is now, I can create a master page, include everything once and then use a proper menu system to link around my application like I can in facebook, etc.<br />
    </span></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samurai-joe.com/./opensocial-and-aspnet/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
