<?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"
	>

<channel>
	<title>technetguy.com</title>
	<atom:link href="http://technetguy.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://technetguy.com/blog</link>
	<description>A way to communicate and learn .Net</description>
	<pubDate>Mon, 01 Jun 2009 21:08:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>BING is live, the msn search is gone.</title>
		<link>http://technetguy.com/blog/2009/06/bing-is-live-the-msn-search-is-gone/</link>
		<comments>http://technetguy.com/blog/2009/06/bing-is-live-the-msn-search-is-gone/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 21:08:06 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[BING]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2009/06/bing-is-live-the-msn-search-is-gone/</guid>
		<description><![CDATA[Watched the live video of the BING, I really liked the idea about the categorized search result. Also found that http://search.msn.com is already redirected to the http://www.bing.com
&#160;
Also noticed a unofficial definition of the BING&#160; &#8212; :-)&#160; &#34;BING = But its not Google&#34;
It’s interesting that Microsoft is taking the social media like Twitter to do the [...]]]></description>
			<content:encoded><![CDATA[<p>Watched the live video of the BING, I really liked the idea about the categorized search result. Also found that <a href="http://search.msn.com">http://search.msn.com</a> is already redirected to the <a href="http://www.bing.com">http://www.bing.com</a></p>
<p>&#160;</p>
<p>Also noticed a unofficial definition of the BING&#160; &#8212; :-)&#160; &quot;BING = But its not Google&quot;</p>
<p>It’s interesting that Microsoft is taking the social media like Twitter to do the release announcement as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2009/06/bing-is-live-the-msn-search-is-gone/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WCF RESTFul Service</title>
		<link>http://technetguy.com/blog/2009/04/wcf-restful-service/</link>
		<comments>http://technetguy.com/blog/2009/04/wcf-restful-service/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 04:15:44 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[Asp.Net]]></category>

		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2009/04/wcf-restful-service/</guid>
		<description><![CDATA[Creating a RESTFul web service in WCF can be easier than a normal web service!? Some of my friends did not believe and they even argued that REST is not considered as a web service.So I figured it out by using the http://en.wikipedia.org/wiki/Web_service . Thanks wikipedia!
With the installation of the WCF REST Service Start Kit [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a RESTFul web service in WCF can be easier than a normal web service!? Some of my friends did not believe and they even argued that REST is not considered as a web service.So I figured it out by using the <a title="http://en.wikipedia.org/wiki/Web_service" href="http://en.wikipedia.org/wiki/Web_service">http://en.wikipedia.org/wiki/Web_service</a> . Thanks wikipedia!</p>
<p>With the installation of the <a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644" target="_blank">WCF REST Service Start Kit</a> , the RESTFul web service can be created by using a wizard and you can create multi types of service as well.Before you install this start kit, you have to install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E" target="_blank">visual studio 2008 sp1</a> and <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;displaylang=en" target="_blank">.net framework 3.5 sp1</a>. </p>
<p>If you had the experience with the WCF web service, you have to live with the service.svc. I HATE the .svc extension. It’s OK if we create the normal web service, but if it’s for a RESTFul web service, only this name convention will kill the idea. This can be resolved easier under IIS 7 by creating a URLrewrite module,YES, it’s easy (OK, not hard) and cool. But if you have to live under IIS 6, what you need to do?!</p>
<p>Thanks God and please Hate MS, there is one great solution for it.You can go to the <a href="http://www.codeplex.com/IIRF" target="_blank">Ionic&#8217;s Isapi Rewrite Filter</a> and start to use it .It’s a great open source project and hosted at codeplex.com. It support the regular expression to define the rewriting rules. I used it in my projects and did not find any problems.</p>
<p>That’s it and hope you will like the new RESTFul web service world.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2009/04/wcf-restful-service/feed/</wfw:commentRss>
		</item>
		<item>
		<title>LINQ to Flickr support for Photo search</title>
		<link>http://technetguy.com/blog/2009/04/linq-to-flickr-support-for-photo-search/</link>
		<comments>http://technetguy.com/blog/2009/04/linq-to-flickr-support-for-photo-search/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 03:01:39 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2009/04/linq-to-flickr-support-for-photo-search/</guid>
		<description><![CDATA[&#160;
Long time ago, I had one post said that the NFlickr is going to support the LINQ , because my new baby was born at last Dec and I could not get any chance until yesterday. So NOW I will announce that the first version of the LINQ to Flickr is ready for the Alpha [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Long time ago, I had one <a href="http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/" target="_blank">post</a> said that the <a href="http://www.codeplex.com/NFlickr" target="_blank">NFlickr</a> is going to support the LINQ , because my new baby was born at last Dec and I could not get any chance until yesterday. So NOW I will announce that the first version of the LINQ to Flickr is ready for the Alpha test.</p>
<p>To search your photos can be as simple as this</p>
<p>&nbsp;</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span> PhotoList list = <span class="kwrd">new</span> PhotoList(service);</pre>
<pre><span class="lnum">   2:  </span>            var photos = from photo <span class="kwrd">in</span> list</pre>
<pre class="alt"><span class="lnum">   3:  </span>                              <span class="kwrd">where</span> photo.TagName == <span class="str">"Yang"</span> &amp;&amp; photo.Family == <span class="kwrd">true</span> </pre>
<pre><span class="lnum">   4:  </span>                              select photo;</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>
<p>&nbsp;</p>
<p>Of course, you need to initialize the service and you have to follow the Flickr development document. But it’s already done in <a href="http://www.codeplex.com/NFlickr" target="_blank">NFlickr</a> <img src='http://technetguy.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In the next few posts, I will share the experience with the LINQ to Flickr development. Hopefully baby will agree and give me more time <img src='http://technetguy.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2009/04/linq-to-flickr-support-for-photo-search/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The problem of JSON and how to fix it(Update with code sample)</title>
		<link>http://technetguy.com/blog/2008/11/ajaxaspnet/</link>
		<comments>http://technetguy.com/blog/2008/11/ajaxaspnet/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 18:13:32 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[Asp.Net]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/ajaxaspnet/</guid>
		<description><![CDATA[In AJAX world, JSON is one of the most popular implementation, Asp.Net AJAX is using this concept, and it really works great.
But in some very special situation, JSON could cause some unexpected problems.For example, if the user want to submit a huge document on the local to the server side, you will find it takes [...]]]></description>
			<content:encoded><![CDATA[<p>In AJAX world, JSON is one of the most popular implementation, Asp.Net AJAX is using this concept, and it really works great.</p>
<p>But in some very special situation, JSON could cause some unexpected problems.For example, if the user want to submit a huge document on the local to the server side, you will find it takes too much time before the server-side gets requested.Why?</p>
<p>We knew that one task for the so-call AJAX framework is to serialize the data and on the server-side to de-serialize the data. But if the data is huge, then the serialization itself will take a while.</p>
<p>If the server only needs the body of the huge document, why do we need to serialize the client -side data? In this case, we don&#8217;t need the serialization at all and we can use the XmlHttp post to implement the AJAX call ourselves.</p>
<p><em>(I read some comments and feedbacks said it I can post some simple example code, that will be helpful, I am sorry for that I did not do that at beginning)<br /></em></p>
<p>The Javascript AJAX call will be like:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">var</span> xmlpost;</pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">function</span> OnXmlPostRequestComplete(args){}</pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">function</span> OnXmlPostRequestTimeout(){alert(<span class="str">'Timeout not implemented.'</span>);}</pre>
<pre><span class="lnum">   4:  </span><span class="kwrd">function</span> OnXmlPostRequestError(){alert(<span class="str">'Exception not implemented'</span>);}</pre>
<pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">function</span> AjaxSaveDocument(documentText,OnPostRequestComplete,OnPostRequestError,OnWebRequestTimeout)</pre>
<pre><span class="lnum">   6:  </span>{</pre>
<pre class="alt"><span class="lnum">   7:  </span>    xmlpost=<span class="kwrd">new</span> ActiveXObject(<span class="str">"Microsoft.XMLHTTP"</span>)</pre>
<pre><span class="lnum">   8:  </span>    OnXmlPostWebRequestComplete=OnPostRequestComplete;</pre>
<pre class="alt"><span class="lnum">   9:  </span>    OnXmlPostWebRequestError=OnPostRequestError;</pre>
<pre><span class="lnum">  10:  </span>    OnXmlPostWebRequestTimeout=OnWebRequestTimeout;</pre>
<pre class="alt"><span class="lnum">  11:  </span>    </pre>
<pre><span class="lnum">  12:  </span>    xmlpost.open(<span class="str">"POST"</span>, <span class="str">"AjaxSaveDocument.aspx"</span>);</pre>
<pre class="alt"><span class="lnum">  13:  </span>    xmlpost.onreadystatechange=OnPostRequestCompleted;</pre>
<pre><span class="lnum">  14:  </span>    xmlpost.setRequestHeader(<span class="str">"Content-Type"</span>, <span class="str">"text/html; charset=utf-8"</span>)</pre>
<pre class="alt"><span class="lnum">  15:  </span>    xmlpost.send(documentText)</pre>
<pre><span class="lnum">  16:  </span>}</pre>
<pre class="alt"><span class="lnum">  17:  </span>&nbsp;</pre>
<pre><span class="lnum">  18:  </span><span class="kwrd">function</span> OnPostRequestCompleted() </pre>
<pre class="alt"><span class="lnum">  19:  </span>{ </pre>
<pre><span class="lnum">  20:  </span>    <span class="kwrd">if</span> (xmlhttp.readyState==4) {</pre>
<pre class="alt"><span class="lnum">  21:  </span>    </pre>
<pre><span class="lnum">  22:  </span>        <span class="kwrd">if</span>(xmlhttp.statusCode&gt;299)</pre>
<pre class="alt"><span class="lnum">  23:  </span>        {</pre>
<pre><span class="lnum">  24:  </span>            OnXmlPostRequestTimeout();</pre>
<pre class="alt"><span class="lnum">  25:  </span>        }</pre>
<pre><span class="lnum">  26:  </span>        <span class="kwrd">else</span></pre>
<pre class="alt"><span class="lnum">  27:  </span>        {</pre>
<pre><span class="lnum">  28:  </span>           <span class="kwrd">try</span></pre>
<pre class="alt"><span class="lnum">  29:  </span>           {</pre>
<pre><span class="lnum">  30:  </span>              OnXmlPostRequestComplete(xmlhttp.responseText);               </pre>
<pre class="alt"><span class="lnum">  31:  </span>           }</pre>
<pre><span class="lnum">  32:  </span>           <span class="kwrd">catch</span>(error)</pre>
<pre class="alt"><span class="lnum">  33:  </span>           {</pre>
<pre><span class="lnum">  34:  </span>              OnXmlPostRequestError();</pre>
<pre class="alt"><span class="lnum">  35:  </span>           }</pre>
<pre><span class="lnum">  36:  </span>        }</pre>
<pre class="alt"><span class="lnum">  37:  </span>     }</pre>
<pre><span class="lnum">  38:  </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>The Javascript consumer call will be like :</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">var</span> documentText = document.getElementById(<span class="str">"txtBody"</span>).value;</pre>
<pre><span class="lnum">   2:  </span>    AjaxSaveDocument(documentText,OnCustomerizedAjaxCallComplete);</pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">function</span> OnCustomerizedAjaxCallComplete(args)</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>       alert(<span class="str">"Save Result is "</span> + args);</pre>
<pre><span class="lnum">   6:  </span>    }</pre>
<pre>&nbsp;</pre>
<pre>On the server side code-behind, the C# code will get the http request stream and parse the stream to the string, then put the business logic</pre>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> AjaxSaveDocument : System.Web.UI.Page</pre>
<pre><span class="lnum">   2:  </span>{</pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">private</span> <span class="kwrd">string</span> RequestInputStreamToString()</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">using</span> (StreamReader reader = <span class="kwrd">new</span> StreamReader(Request.InputStream))</pre>
<pre><span class="lnum">   6:  </span>        {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            <span class="kwrd">string</span> contents = reader.ReadToEnd();</pre>
<pre><span class="lnum">   8:  </span>            <span class="kwrd">return</span> contents;</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>    <span class="kwrd">protected</span> <span class="kwrd">void</span> Page_Load(<span class="kwrd">object</span> sender, EventArgs e)</pre>
<pre><span class="lnum">  12:  </span>    {</pre>
<pre class="alt"><span class="lnum">  13:  </span>        <span class="kwrd">if</span> (Request.HttpMethod == <span class="str">"POST"</span>)</pre>
<pre><span class="lnum">  14:  </span>        {</pre>
<pre class="alt"><span class="lnum">  15:  </span>            <span class="kwrd">string</span> strmContents = RequestInputStreamToString();</pre>
<pre><span class="lnum">  16:  </span>           </pre>
<pre class="alt"><span class="lnum">  17:  </span>            Response.Clear();</pre>
<pre><span class="lnum">  18:  </span>            Response.Write(<span class="kwrd">string</span>.Format(<span class="str">"Content length is {0}"</span>,strmContents.Length));</pre>
<pre class="alt"><span class="lnum">  19:  </span>            Response.End();</pre>
<pre><span class="lnum">  20:  </span>        }</pre>
<pre class="alt"><span class="lnum">  21:  </span>    }</pre>
<pre><span class="lnum">  22:  </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>
</div>
<div class="csharpcode">&nbsp;</div>
<div class="csharpcode">I will try Casey Barton&#8217;s suggestion to see will that work and how it will work. I tried that solution before but I did not try very hard on it since I like to everything from scratch <img src='http://technetguy.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </div>
<div class="csharpcode">Here is the feedback from Casey Barton:</div>
<div class="csharpcode"><u><em>&#8220;</em></u></div>
<p><u><em>Tuesday, November 18, 2008 10:03 AM by Casey Barton </em></u></p>
<p><u><em>The *real* fix would be to implement asynchronous (de)serialization for AJAX requests and responses, that operates on the HTTP stream as it transfers data.</em></u> </p>
<div class="csharpcode"><u><em>&#8220;</em></u></div>
<div class="csharpcode"><em><u></u></em>&nbsp;</div>
<div class="csharpcode">Thanks for you guys great feedback.</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>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/ajaxaspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The problem of JSON and how to fix it</title>
		<link>http://technetguy.com/blog/2008/11/ajxaspnet/</link>
		<comments>http://technetguy.com/blog/2008/11/ajxaspnet/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 04:38:05 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[Asp.Net]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/ajxaspnet/</guid>
		<description><![CDATA[In AJAX world, JSON is one of the most popular implementation, Asp.Net AJAX is using this concept, and it really works great.
But in some very special situation, JSON could cause some unexpected problems.For example, if the user want to submit a huge document on the local to the server side, you will find it takes [...]]]></description>
			<content:encoded><![CDATA[<p>In AJAX world, JSON is one of the most popular implementation, Asp.Net AJAX is using this concept, and it really works great.</p>
<p>But in some very special situation, JSON could cause some unexpected problems.For example, if the user want to submit a huge document on the local to the server side, you will find it takes too much time before the server-side gets requested.Why?</p>
<p>We knew that one task for the so-call AJAX framework is to serialize the data and on the server-side to de-serialize the data. But if the data is huge, then the serialization itself will take a while.</p>
<p>If the server only needs the body of the huge document, why do we need to serialize the client -side data? In this case, we don&#8217;t need the serialization at all and we can use the XmlHttp post to implement the AJAX call ourselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/ajxaspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multi culture programming in Asp.Net</title>
		<link>http://technetguy.com/blog/2008/11/aspnet/</link>
		<comments>http://technetguy.com/blog/2008/11/aspnet/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 06:08:35 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[Asp.Net]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/aspnet/</guid>
		<description><![CDATA[Asp.Net provide a very powerful multi culture programming pattern.In this post , we will discuss specially under the user control level.
Last weekend, one of my friends asked the question about the user control multi culture programming problem. He could not make it work at that time and I was in the middle of the NFlickr [...]]]></description>
			<content:encoded><![CDATA[<p>Asp.Net provide a very powerful multi culture programming pattern.In this post , we will discuss specially under the user control level.</p>
<p>Last weekend, one of my friends asked the question about the user control multi culture programming problem. He could not make it work at that time and I was in the middle of the <a href="http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/" target="_blank">NFlickr Release</a> , so I promised to write a post about this problem.</p>
<p>First, I did not know what exactly the problem was, but I will try to use the standard way to implement it.</p>
<p>The user control is &#8220;Login.ascx&#8221; and the html markup is</p>
<pre class="csharpcode"><span class="asp">&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="Login.ascx.cs"   Inherits="UserControl_Login"  %&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">="lblUser"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="UserId"</span>
    <span class="attr">meta:resourcekey</span><span class="kwrd">="lblUserResource1"</span> <span class="kwrd">/&gt;</span> <span class="kwrd">&lt;</span><span class="html">asp:TextBox</span> <span class="attr">ID</span><span class="kwrd">="txtUser"</span>
    <span class="attr">runat</span><span class="kwrd">="server"</span>  <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">="lblPassword"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="UserId"</span>
    <span class="attr">meta:resourcekey</span><span class="kwrd">="lblPasswordResource1"</span> <span class="kwrd">/&gt;</span> <span class="kwrd">&lt;</span><span class="html">asp:TextBox</span> <span class="attr">ID</span><span class="kwrd">="txtPassword"</span>
    <span class="attr">TextMode</span><span class="kwrd">="Password"</span> <span class="attr">runat</span><span class="kwrd">="server"</span>  <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Button</span> <span class="attr">ID</span><span class="kwrd">="cmdLogin"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="Login"</span>
    <span class="kwrd">/&gt;</span></pre>
<p><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>Change to the design mode and select the menu tools-&gt;Generate the resource file. This tools will create the App_LocalResources folder and Login.ascx.resx file automatically. After this operation , the file content will be changed to </p>
<pre class="csharpcode"><span class="asp">&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="Login.ascx.cs"   Inherits="UserControl_Login"  %&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">="lblUser"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="UserId"</span>
    <span class="attr">meta:resourcekey</span><span class="kwrd">="lblUserResource1"</span> <span class="kwrd">/&gt;</span> <span class="kwrd">&lt;</span><span class="html">asp:TextBox</span> <span class="attr">ID</span><span class="kwrd">="txtUser"</span>
    <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">meta:resourcekey</span><span class="kwrd">="txtUserResource1"</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">="lblPassword"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="UserId"</span>
    <span class="attr">meta:resourcekey</span><span class="kwrd">="lblPasswordResource1"</span> <span class="kwrd">/&gt;</span> <span class="kwrd">&lt;</span><span class="html">asp:TextBox</span> <span class="attr">ID</span><span class="kwrd">="txtPassword"</span>
    <span class="attr">TextMode</span><span class="kwrd">="Password"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">meta:resourcekey</span><span class="kwrd">="txtPasswordResource1"</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">asp:Button</span> <span class="attr">ID</span><span class="kwrd">="cmdLogin"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="Login"</span>
    <span class="attr">meta:resourcekey</span><span class="kwrd">="cmdLoginResource1"</span> <span class="kwrd">/&gt;</span></pre>
<p>The trick is the meta:resourceKey , in the Login.ascx.resx file, there will be a list of keys which&nbsp; will like cmdLoginResource1.Text,txtPasswordResource1.Text, etc.</p>
<p>If we want to support the Canada French, what we need to do is just create a french version of the resource, the name convention will be Login.ascx.fr-CA.resx</p>
<p>Now, we can go back to the default.aspx file which is the place holder for the user control</p>
<pre class="csharpcode"><span class="asp">&lt;%@ Page Language="C#" AutoEventWireup="true"   CodeFile="Default.aspx.cs"  Inherits="_Default" %&gt;</span>

<span class="asp">&lt;%@ Register src="UserControl/Login.ascx" tagname="Login" tagprefix="uc1" %&gt;</span>

<span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> <span class="kwrd">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span class="kwrd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span><span class="kwrd">="http://www.w3.org/1999/xhtml"</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">="form1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>

        <span class="kwrd">&lt;</span><span class="html">uc1:Login</span> <span class="attr">ID</span><span class="kwrd">="Login1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">="lblMessage"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Text</span><span class="kwrd">="Message"</span>
            <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span>
</pre>
<p><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>When we run this file , we will find that the multi-culture does not work!! Why? </p>
<p>By default, if we don&#8217;t write any code and want to have the multi-culture feature, we need to enable the multi-culture for this page.We need to change the page register statement.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>After we had this line of change, we will have the full set of multi-culture support without writing a line of code.</p>
<p>The source code can be downloaded at <a href="http://technetguy.com/Download/blog/UserControlCulture.rar" target="_blank">http://technetguy.com/Download/blog/UserControlCulture.rar</a></p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The first version of the NFlickr released</title>
		<link>http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/</link>
		<comments>http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 02:48:55 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[NFlickr]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/</guid>
		<description><![CDATA[Yesterday, the first Alpha&#160; version of the NFlickr was released.This version was fully written by the .Net 3.5 and using the provider concept.For example, if you don&#8217;t like the built-in encryption or you don&#8217;t like the implementation of the http communication. you can use the same interface of the provider.
From the functionality part, this version [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, the first Alpha&nbsp; version of the <a href="http://www.codeplex.com/NFlickr" target="_blank">NFlickr</a> was released.This version was fully written by the .Net 3.5 and using the provider concept.For example, if you don&#8217;t like the built-in encryption or you don&#8217;t like the implementation of the http communication. you can use the same interface of the provider.</p>
<p>From the functionality part, this version will have the below support:</p>
<p>1. Login to the Flickr Service<br />2. Create the PhotoSet.<br />3. Upload the photo<br />4. Add the photo to a photoSet.<br />5. Search the photo based on the privacy, tags.
<p>&nbsp;
<p>In the next version of the release, the <a href="http://www.codeplex.com/NFlickr" target="_blank">NFlickr</a> will have those feature.
<p>1.LINQ to Flickr support for Photo search (This will be the asset :))<br />2. Get the photo Information.<br />3. Update the photo information, privacy, Title,etc
<p>&nbsp;
<p>Welcome to provide the suggestion and feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/the-first-version-of-the-nflickr-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is silverlight application the windows or web?</title>
		<link>http://technetguy.com/blog/2008/11/is-silverlight-application-the-windows-or-web/</link>
		<comments>http://technetguy.com/blog/2008/11/is-silverlight-application-the-windows-or-web/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 04:39:42 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/is-silverlight-application-the-windows-or-web/</guid>
		<description><![CDATA[Before we started to develop a silverlight application, does anyone ask the question? Is silverlight the windows or web?
The short answer is Windows, but wait&#8230;.
All the code was executed on the client side, the code was download was downloaded to the client side.It has to be executed under the silverlight ActiveX control or browser plugin(For [...]]]></description>
			<content:encoded><![CDATA[<p>Before we started to develop a silverlight application, does anyone ask the question? Is silverlight the windows or web?</p>
<p>The short answer is Windows, but wait&#8230;.</p>
<p>All the code was executed on the client side, the code was download was downloaded to the client side.It has to be executed under the silverlight ActiveX control or browser plugin(For Firefox, Chrome, etc).</p>
<p>But why we still call the silverlight as a web application? Because it can interact with the HTML Dom, it can access the IIS by using the WCF, REST service. It&#8217;s running under the browser. It&#8217;s the light version of&nbsp; WPF and it&#8217;s even called WPF/E!</p>
<p>So I will rather consider the silverlight as a web application , but I will be more concerned about the security while I am developing my application because the code was executed at the client side.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/is-silverlight-application-the-windows-or-web/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using the DOM to control the element(TreeView) inside Silverlight</title>
		<link>http://technetguy.com/blog/2008/11/using-the-dom-to-control-the-elementtreeview-inside-silverlight/</link>
		<comments>http://technetguy.com/blog/2008/11/using-the-dom-to-control-the-elementtreeview-inside-silverlight/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 03:55:34 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/using-the-dom-to-control-the-elementtreeview-inside-silverlight/</guid>
		<description><![CDATA[In our Update the Silverlight toolkit(AutoCompleteBox) With the HTML DOM value post, we talked about the interacting between the Silverlight application and html DOM. It&#8217;s about using the Silverlight to access the DOM. Today we are going to discuss&#160; using the DOM to access the Silverlight.
In the post Using the Silverlight toolkit build a online [...]]]></description>
			<content:encoded><![CDATA[<p>In our <a href="http://weblogs.asp.net/robertxue/archive/2008/11/13/update-the-silverlight-toolkit-autocompletebox-with-the-html-dom-value.aspx" target="_blank">Update the Silverlight toolkit(AutoCompleteBox) With the HTML DOM value</a> post, we talked about the interacting between the Silverlight application and html DOM. It&#8217;s about using the Silverlight to access the DOM. Today we are going to discuss&nbsp; using the DOM to access the Silverlight.</p>
<p>In the post <a href="http://weblogs.asp.net/robertxue/archive/2008/11/10/using-the-silverlight-toolkit-build-a-online-treeview.aspx" target="_blank">Using the Silverlight toolkit build a online TreeView</a>, we had a demo application to demo a buddy list tree using the Silverlight toolkit.Today we will wrote a more complex application to update the online and offline buddy members.</p>
<p>To make thing more difficult, we limited the require to get the buddy info from the html element which is out side of the Silverlight application.</p>
<p>Before we started, we need to introduce a new concept called <a href="http://msdn.microsoft.com/en-us/library/cc645076(VS.95).aspx" target="_blank">Bridge Pattern</a> , and we need to know a trick attribute <em>&#8220;ScriptableMember()&#8221;.</em></p>
<p>The Silverlight code will be like</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>       [ScriptableMember()]</pre>
<pre><span class="lnum">   2:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> AddOnline(<span class="kwrd">string</span> name)</pre>
<pre class="alt"><span class="lnum">   3:  </span>        {</pre>
<pre><span class="lnum">   4:  </span>            TreeViewItem onlineItem = (TreeViewItem)treeview.Items[0];</pre>
<pre class="alt"><span class="lnum">   5:  </span>            TreeViewItem buddy1 = <span class="kwrd">new</span> TreeViewItem();</pre>
<pre><span class="lnum">   6:  </span>            buddy1.Header = name;</pre>
<pre class="alt"><span class="lnum">   7:  </span>            onlineItem.Items.Add(buddy1);</pre>
<pre><span class="lnum">   8:  </span>            <span class="kwrd">int</span> count = onlineItem.Items.Count;</pre>
<pre class="alt"><span class="lnum">   9:  </span>            onlineItem.Header = <span class="kwrd">string</span>.Format(<span class="str">"online({0})"</span>, count);</pre>
<pre><span class="lnum">  10:  </span>        }</pre>
<pre class="alt"><span class="lnum">  11:  </span>        [ScriptableMember()]</pre>
<pre><span class="lnum">  12:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> AddOffline(<span class="kwrd">string</span> name)</pre>
<pre class="alt"><span class="lnum">  13:  </span>        {</pre>
<pre><span class="lnum">  14:  </span>            TreeViewItem offlineItem = (TreeViewItem)treeview.Items[1];</pre>
<pre class="alt"><span class="lnum">  15:  </span>            TreeViewItem offlineContact = <span class="kwrd">new</span> TreeViewItem();</pre>
<pre><span class="lnum">  16:  </span>            offlineContact.Header = name;</pre>
<pre class="alt"><span class="lnum">  17:  </span>            offlineItem.Items.Add(offlineContact);</pre>
<pre><span class="lnum">  18:  </span>            <span class="kwrd">int</span> count = offlineItem.Items.Count;</pre>
<pre class="alt"><span class="lnum">  19:  </span>            offlineItem.Header = <span class="kwrd">string</span>.Format(<span class="str">"offline({0})"</span>, count);</pre>
<pre><span class="lnum">  20:  </span>        }</pre>
<pre class="alt"><span class="lnum">  21:  </span>        <span class="kwrd">public</span> Page()</pre>
<pre><span class="lnum">  22:  </span>        {</pre>
<pre class="alt"><span class="lnum">  23:  </span>            InitializeComponent();</pre>
<pre><span class="lnum">  24:  </span>            TreeViewItem onlineItem = <span class="kwrd">new</span> TreeViewItem();</pre>
<pre class="alt"><span class="lnum">  25:  </span>            onlineItem.Header = <span class="str">"Online(0)"</span>;</pre>
<pre><span class="lnum">  26:  </span>            treeview.Items.Add(onlineItem);</pre>
<pre class="alt"><span class="lnum">  27:  </span>            AddOnline(<span class="str">"Robert1"</span>);</pre>
<pre><span class="lnum">  28:  </span>            AddOnline(<span class="str">"Robert2"</span>);</pre>
<pre class="alt"><span class="lnum">  29:  </span>            TreeViewItem offlineItem = <span class="kwrd">new</span> TreeViewItem();</pre>
<pre><span class="lnum">  30:  </span>            offlineItem.Header = <span class="str">"Offline(0)"</span>;</pre>
<pre class="alt"><span class="lnum">  31:  </span>            treeview.Items.Add(offlineItem);</pre>
<pre><span class="lnum">  32:  </span>            AddOffline(<span class="str">"Roboo1"</span>);</pre>
<pre><span class="lnum">  33:  </span>        }</pre>
</div>
<p><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>
<p>You should notice that the AddOnline and AddOffline methods were marked by the attribute [ScriptableMember()]</p>
<p>Another trick will be how can we get the Silverlight object in the DOM script which will be the JavaScript in most case. </p>
<pre class="csharpcode"> <span class="kwrd">&lt;</span><span class="html">asp:Silverlight</span> <span class="attr">ID</span><span class="kwrd">="Xaml1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Source</span><span class="kwrd">="~/ClientBin/ToolboxTest.xap"</span> <span class="attr">MinimumVersion</span><span class="kwrd">="2.0.31005.0"</span> <span class="attr">Width</span><span class="kwrd">="100%"</span> <span class="attr">Height</span><span class="kwrd">="100%"</span> <span class="attr">OnPluginLoaded</span><span class="kwrd">="silverLightLoaded"</span> <span class="kwrd">/&gt;</span></pre>
<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>As you can see, there is one&nbsp; OnPluginLoaded even and we will register this event by using the JavaScript function</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>       <span class="kwrd">var</span> silverlight = <span class="kwrd">null</span>;</pre>
<pre><span class="lnum">   2:  </span>        </pre>
<pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">function</span> silverLightLoaded(sender) {</pre>
<pre><span class="lnum">   4:  </span>            silverlight = sender.get_element();</pre>
<pre class="alt"><span class="lnum">   5:  </span>            </pre>
<pre><span class="lnum">   6:  </span>        }</pre>
</div>
<p>The full html source will like</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   2:  </span>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>ToolboxTest<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">type</span><span class="kwrd">="text/javascript"</span> <span class="attr">language</span><span class="kwrd">="javascript"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">var</span> silverlight = <span class="kwrd">null</span>;</pre>
<pre class="alt"><span class="lnum">   5:  </span>        </pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">function</span> silverLightLoaded(sender) {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            silverlight = sender.get_element();</pre>
<pre><span class="lnum">   8:  </span>            </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>        <span class="kwrd">function</span> Button1_onclick() {</pre>
<pre><span class="lnum">  12:  </span>            </pre>
<pre class="alt"><span class="lnum">  13:  </span>            <span class="kwrd">var</span> value = document.getElementById(<span class="str">"DataSource"</span>).value;</pre>
<pre><span class="lnum">  14:  </span>            silverlight.Content.BuddyList.AddOnline(value);</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>    <span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  18:  </span><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  19:  </span><span class="kwrd">&lt;</span><span class="html">body</span> <span class="attr">style</span><span class="kwrd">="height:100%;margin:0;"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  20:  </span>    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">="form1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">style</span><span class="kwrd">="height:100%;"</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  21:  </span>        <span class="kwrd">&lt;</span><span class="html">asp:ScriptManager</span> <span class="attr">ID</span><span class="kwrd">="ScriptManager1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ScriptManager</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  22:  </span>        <span class="kwrd">&lt;</span><span class="html">div</span>  <span class="attr">style</span><span class="kwrd">="height:100%;"</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  23:  </span>            <span class="kwrd">&lt;</span><span class="html">asp:Silverlight</span> <span class="attr">ID</span><span class="kwrd">="Xaml1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">Source</span><span class="kwrd">="~/ClientBin/ToolboxTest.xap"</span> <span class="attr">MinimumVersion</span><span class="kwrd">="2.0.31005.0"</span> <span class="attr">Width</span><span class="kwrd">="100%"</span> <span class="attr">Height</span><span class="kwrd">="100%"</span> <span class="attr">OnPluginLoaded</span><span class="kwrd">="silverLightLoaded"</span> <span class="kwrd">/&gt;</span></pre>
<pre><span class="lnum">  24:  </span>        <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  25:  </span>        <span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">="text"</span> <span class="attr">id</span><span class="kwrd">="DataSource"</span> <span class="attr">name</span><span class="kwrd">="DataSource"</span> <span class="kwrd">/&gt;</span></pre>
<pre><span class="lnum">  26:  </span>        <span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">type</span>=<span class="attr">button</span> <span class="attr">value</span><span class="kwrd">="See"</span>  <span class="attr">onclick</span><span class="kwrd">="Button1_onclick()"</span> <span class="kwrd">/&gt;</span></pre>
<pre class="alt"><span class="lnum">  27:  </span>    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">  28:  </span><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">  29:  </span><span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</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>If you want to run this code, nothing will happen! The reason is the Javascript does not have a way to access the content inside the Silverlight now. So there is one line&nbsp; of code need to be added.</p>
<p>At the end of the Page load event at Silverlight, we should register a object for the outside to be referenced.</p>
<p>&nbsp;</p>
<div class="csharpcode">
<pre><span class="lnum">   1:  </span> HtmlPage.RegisterScriptableObject(<span class="str">"BuddyList"</span>, <span class="kwrd">this</span>);</pre>
<pre>&nbsp;</pre>
<pre>That's it.Now we can click the html button and get the access of the silverlight TreeView control.</pre>
<pre>The source code can be downloaded at <a href="http://technetguy.com/Download/blog/SilverLight_BuddyList_Js.rar" target="_blank">http://technetguy.com/Download/blog/SilverLight_BuddyList_Js.rar</a></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>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/using-the-dom-to-control-the-elementtreeview-inside-silverlight/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Update the Silverlight toolkit(AutoCompleteBox) With the HTML DOM value</title>
		<link>http://technetguy.com/blog/2008/11/update-the-silverlight-toolkitautocompletebox-with-the-html-dom-value/</link>
		<comments>http://technetguy.com/blog/2008/11/update-the-silverlight-toolkitautocompletebox-with-the-html-dom-value/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 05:15:23 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://technetguy.com/blog/2008/11/update-the-silverlight-toolkitautocompletebox-with-the-html-dom-value/</guid>
		<description><![CDATA[The silverlight toolkit provided the AutoCompleteBox and We already had one post talking about the usage about it.
This post will focus on the way we can update the content of the AutoCompleteBox by using the value from the HTML DOM value.
The initialized code was not changed and we only added a new button on the [...]]]></description>
			<content:encoded><![CDATA[<p>The silverlight toolkit provided the <a href="http://www.codeplex.com/Silverlight/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%201&amp;referringTitle=Home&amp;ANCHOR#AutoCompleteBox" target="_blank">AutoCompleteBox</a> and We already had one <a href="http://technetguy.com/blog/2008/10/using-the-silverlight-toolkit-to-create-a-web-application/" target="_blank">post</a> talking about the usage about it.</p>
<p>This post will focus on the way we can update the content of the AutoCompleteBox by using the value from the HTML DOM value.</p>
<p>The initialized code was not changed and we only added a new button on the silverlight control which is the </p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">Height</span><span class="kwrd">="24"</span> <span class="attr">HorizontalAlignment</span><span class="kwrd">="Right"</span> <span class="attr">Margin</span><span class="kwrd">="0,20,123,0"</span> <span class="attr">VerticalAlignment</span><span class="kwrd">="Top"</span> <span class="attr">Width</span><span class="kwrd">="76"</span> <span class="attr">Click</span><span class="kwrd">="Button_Click"</span> <span class="attr">Content</span><span class="kwrd">="Refresh"</span><span class="kwrd">/&gt;</span></pre>
<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 we go to the web page ToolboxTestTestPage.aspx to add a new Textarea input box which will provide the content.</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">textarea</span> <span class="attr">id</span><span class="kwrd">="DataSource"</span> <span class="attr">name</span><span class="kwrd">="DataSource"</span> <span class="attr">cols</span><span class="kwrd">="10"</span> <span class="attr">rows</span><span class="kwrd">="5"</span><span class="kwrd">&gt;&lt;/</span><span class="html">textarea</span><span class="kwrd">&gt;</span></pre>
<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>The real problem is about the interacting the silverlight application and the HTML DOM object.</p>
<p>The first code I tried is to use the common sense way which is </p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>           HtmlElement datasource= HtmlPage.Document.GetElementById(<span class="str">"DataSource"</span>);</pre>
<pre><span class="lnum">   2:  </span>            <span class="kwrd">if</span> (datasource != <span class="kwrd">null</span>)</pre>
<pre class="alt"><span class="lnum">   3:  </span>            {</pre>
<pre><span class="lnum">   4:  </span>                <span class="kwrd">string</span> content = datasource.GetProperty(<span class="str">"innerHTML"</span>) <span class="kwrd">as</span> <span class="kwrd">string</span>;</pre>
<pre class="alt"><span class="lnum">   5:  </span>                List&lt;<span class="kwrd">string</span>&gt; list=content.Split(<span class="str">"\n"</span>.ToCharArray()).ToList();</pre>
<pre><span class="lnum">   6:  </span>                txtAutoComplete.ItemsSource = list;</pre>
<pre class="alt"><span class="lnum">   7:  </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>But I find it&#8217;s almost no way for me get the user input value, so I changed my way to using the Javascript.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>           <span class="kwrd">string</span> content = (<span class="kwrd">string</span>)HtmlPage.Window.Invoke(<span class="str">"GetDataSource"</span>, <span class="kwrd">null</span>);</pre>
<pre><span class="lnum">   2:  </span>            List&lt;<span class="kwrd">string</span>&gt; list = content.Split(<span class="str">"\n"</span>.ToCharArray()).ToList();</pre>
<pre class="alt"><span class="lnum">   3:  </span>            txtAutoComplete.ItemsSource = list;</pre>
</div>
<p><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><em>when I did this , I realized that how cool and convenient will be when we have the C# dynamic.</em>&nbsp;</p>
<p>And the Javascript on the page is </p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   2:  </span>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>ToolboxTest<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">type</span><span class="kwrd">="text/javascript"</span> <span class="attr">language</span><span class="kwrd">="javascript"</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">function</span> GetDataSource() {</pre>
<pre class="alt"><span class="lnum">   5:  </span>            <span class="kwrd">return</span> $get(<span class="str">"DataSource"</span>, document).value;</pre>
<pre><span class="lnum">   6:  </span>        }</pre>
<pre class="alt"><span class="lnum">   7:  </span>    <span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre>
<pre><span class="lnum">   8:  </span><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</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>Keep in mind , don&#8217;t use the&nbsp; Html.Document.Invoke because the Javascript is an instance of the html window, not the document. In the future post, I will take another way around to getting the silverlight value from the HTML Dom.</p>
]]></content:encoded>
			<wfw:commentRss>http://technetguy.com/blog/2008/11/update-the-silverlight-toolkitautocompletebox-with-the-html-dom-value/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
