<?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>One .NET Way &#187; Programming</title>
	<atom:link href="http://www.onedotnetway.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onedotnetway.com</link>
	<description>Everything .Net</description>
	<lastBuildDate>Thu, 20 May 2010 03:38:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mother Of All SharePoint 2010 Virtual Machines</title>
		<link>http://www.onedotnetway.com/mother-of-all-sharepoint-2010-virtual-machines/</link>
		<comments>http://www.onedotnetway.com/mother-of-all-sharepoint-2010-virtual-machines/#comments</comments>
		<pubDate>Mon, 10 May 2010 01:31:10 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/?p=740</guid>
		<description><![CDATA[This is one Machine to rule them all (I know Lord of Rings is so old school). In the Virtual Machine you will get the following.

Windows Server 2008 R2 Standard Evaluation Edition x64, running as  an Active Directory Domain Controller for the “CONTOSO.COM” domain with  DNS and WINS
Microsoft SQL Server 2008 R2 Enterprise [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/mother-of-all-sharepoint-2010-virtual-machines/">Mother Of All SharePoint 2010 Virtual Machines</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is one Machine to rule them all (I know Lord of Rings is so old school). In the Virtual Machine you will get the following.</p>
<ol>
<li>Windows Server 2008 R2 Standard Evaluation Edition x64, running as  an Active Directory Domain Controller for the “CONTOSO.COM” domain with  DNS and WINS</li>
<li>Microsoft SQL Server 2008 R2 Enterprise Edition with Analysis,  Notification, and Reporting Services</li>
<li>Microsoft Office Communication Server 2007 R2</li>
<li>Microsoft Visual Studio 2010</li>
<li>Microsoft SharePoint Server 2010 Enterprise Edition</li>
<li>Microsoft Office Web Applications</li>
<li>Microsoft FAST Search for SharePoint 2010</li>
<li>Microsoft Project Server 2010</li>
<li>Microsoft Office Professional Plus 2010</li>
<li>Microsoft Visio 2010</li>
<li>Microsoft Project 2010</li>
<li>Microsoft Office Communicator 2007 R2</li>
</ol>
<p>So fireup your <a href="http://www.freedownloadmanager.org/">free download manager</a> and download this absolute SharePoint 2010 nirvana. If you are contrained on bandwidth then just to let you know that full download will set you back by approximately 18GB.</p>
<p>Here is the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=751fa0d1-356c-4002-9c60-d539896c66ce">download link</a>.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/mother-of-all-sharepoint-2010-virtual-machines/">Mother Of All SharePoint 2010 Virtual Machines</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/mother-of-all-sharepoint-2010-virtual-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working With Client ID In ASP.NET 4</title>
		<link>http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/</link>
		<comments>http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 03:54:25 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/</guid>
		<description><![CDATA[ASP.NET 4 allows developers to customize Client Id which gets generated by ASP.NET. Up until now Client Id generated by ASP.NET has been ummm just plain ugly. Other than aesthetics they are also hard to work with in client side scripts. ASP.NET solves this issue to a degree by providing ClientIDMode property. In this post [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/">Working With Client ID In ASP.NET 4</a></p>
]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 4 allows developers to customize Client Id which gets generated by ASP.NET. Up until now Client Id generated by ASP.NET has been ummm just plain ugly. Other than aesthetics they are also hard to work with in client side scripts. ASP.NET solves this issue to a degree by providing ClientIDMode property. In this post we will look at different ways to work with this new feature of ASP.NET 4.</p>
<p>ClientIDMode can be set at Page level or at Control level. Let’s follow with an example of a GridView control. We will set it’s ClientIdMode property to all available options and view the markup. We will bind our GridView to a collection of cities. A city class looks like this.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">City
</span>{
<span style="color: blue">  public string </span>Name { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
<span style="color: blue">  public string </span>Country { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
}</pre>
<p>&#160;</p>
<p>The collection itself can be initialized using this code.</p>
<pre class="code"><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">City</span>&gt; cities =
        <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">City</span>&gt;
        {
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Sydney&quot;</span>, Country = <span style="color: #a31515">&quot;Australia&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;New York&quot;</span>, Country = <span style="color: #a31515">&quot;USA&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Paris&quot;</span>, Country = <span style="color: #a31515">&quot;France&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Milan&quot;</span>, Country = <span style="color: #a31515">&quot;Spain&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Melbourne&quot;</span>, Country = <span style="color: #a31515">&quot;Australia&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Auckland&quot;</span>, Country = <span style="color: #a31515">&quot;New Zealand&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Tokyo&quot;</span>, Country = <span style="color: #a31515">&quot;Japan&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;New Delhi&quot;</span>, Country = <span style="color: #a31515">&quot;India&quot; </span>},
            <span style="color: blue">new </span><span style="color: #2b91af">City</span>{ Name = <span style="color: #a31515">&quot;Hobart&quot;</span>, Country = <span style="color: #a31515">&quot;Australia&quot; </span>}
        };</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Source for our GridView looks like this.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;gridViewCities&quot; </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;False&quot;&gt;
  &lt;</span><span style="color: maroon">Columns</span><span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
      &lt;</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
        &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">Label </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;Label1&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: yellow">&lt;%</span><span style="color: blue"># </span>Bind(&quot;Name&quot;) <span style="background: yellow">%&gt;</span><span style="color: blue">' /&gt;
      &lt;/</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
      &lt;</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
        &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">Label </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;Label2&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: yellow">&lt;%</span><span style="color: blue"># </span>Bind(&quot;Country&quot;) <span style="background: yellow">%&gt;</span><span style="color: blue">' /&gt;
      &lt;/</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: maroon">Columns</span><span style="color: blue">&gt;
&lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView</span><span style="color: blue">&gt;
</span></pre>
<p>&#160;</p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h4>ClientIDMode = “AutoID”</h4>
<p>Using this mode will generate the IDs as it has in earlier versions of ASP.NET.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView
        </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
        </span><span style="color: red">ID</span><span style="color: blue">=&quot;gridViewCities&quot;
        </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;False&quot;
        </span><span style="color: red">ClientIDMode</span><span style="color: blue">=&quot;AutoID&quot;&gt;
</span></pre>
<p>&#160;</p>
<p>HTML generated by AutoID (showing only relevant part).</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image4.png" width="501" height="310" /> </p>
<p>&#160;</p>
<h4>ClientIDMode = “Static”</h4>
<p>Static mode outputs the same ID in HTML as specified in ASP.NET source. </p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView
        </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
        </span><span style="color: red">ID</span><span style="color: blue">=&quot;gridViewCities&quot;
        </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;False&quot;
        </span><span style="color: red">ClientIDMode</span><span style="color: blue">=&quot;Static&quot;&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image5.png" width="342" height="304" /> </p>
<p>Static Mode is not the best for controls such as GridView or any other data control which displays lists of data. As you can see above that all span tags have same IDs. Static Mode is best to be used with other common controls or User Controls.</p>
<p>&#160;</p>
<h4>ClientIDMode = “Predictable”</h4>
<p>Predictable mode concatenates the ID of parent control with the bound value supplied by assigning ClientIDRowSuffix property.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView
        </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;
        </span><span style="color: red">ID</span><span style="color: blue">=&quot;gridViewCities&quot;
        </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;False&quot;
        </span><span style="color: red">ClientIDMode</span><span style="color: blue">=&quot;Predictable&quot;
        </span><span style="color: red">ClientIDRowSuffix</span><span style="color: blue">=&quot;Name&quot;&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image6.png" width="527" height="307" /> </p>
<p>Here we see that our span elements have been named by concatenating the name of GridView + value of Name property. Rather than setting ClientIDRowSuffix to Name property a better candidate would have been an ID property which could be some sort of unique field. But you get the idea, right?</p>
<p>&#160;</p>
<h4>ClientIDMode = “Inherit”</h4>
<p>Inherit is the default mode for all controls. Assigning this mode a control will use the same setting as its parent control. This gives us an idea that we can have different settings for parent and children. Here we are setting ClientIDMode for our first label to be static while the GridView is using AutoID.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;gridViewCities&quot; </span><span style="color: red">AutoGenerateColumns</span><span style="color: blue">=&quot;False&quot; </span></pre>
<pre class="code"><span style="color: blue">  </span><span style="color: red">ClientIDMode</span><span style="color: blue">=&quot;AutoID&quot;&gt;
  &lt;</span><span style="color: maroon">Columns</span><span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
      &lt;</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
        &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">Label </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;Label1&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: yellow">&lt;%</span><span style="color: blue"># </span>Bind(&quot;Name&quot;) <span style="background: yellow">%&gt;</span><span style="color: blue">' </span></pre>
<pre class="code"><span style="color: blue">          </span><span style="color: red">ClientIDMode</span><span style="color: blue">=&quot;Static&quot; /&gt;
      &lt;/</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
    &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
      &lt;</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
        &lt;</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">Label </span><span style="color: red">runat</span><span style="color: blue">=&quot;server&quot; </span><span style="color: red">ID</span><span style="color: blue">=&quot;Label2&quot; </span><span style="color: red">Text</span><span style="color: blue">='</span><span style="background: yellow">&lt;%</span><span style="color: blue"># </span>Bind(&quot;Country&quot;) <span style="background: yellow">%&gt;</span><span style="color: blue">' /&gt;
      &lt;/</span><span style="color: maroon">ItemTemplate</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">TemplateField</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: maroon">Columns</span><span style="color: blue">&gt;
&lt;/</span><span style="color: maroon">asp</span><span style="color: blue">:</span><span style="color: maroon">GridView</span><span style="color: blue">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image7.png" width="510" height="302" /> </p>
<p>We see that our first span uses static client ID but the second span uses inherited scheme for client ID.</p>
<p>&#160;</p>
<h4>Conclusion</h4>
<p>In this post we saw a new feature of ASP.NET 4 which let’s you customize IDs generated in HTML elements. This feature is useful when we need to access controls from client scripts. ASP.NET has been lacking such a feature. Not any more.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/">Working With Client ID In ASP.NET 4</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/working-with-client-id-in-asp-net-4/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Create Breakpoints With Hit Count In Visual Studio 2008</title>
		<link>http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/</link>
		<comments>http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 05:40:26 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/</guid>
		<description><![CDATA[This post shows you how to use Breakpoints in Visual Studio with a hit count. Breakpoints can be described as bread and butter of debugging. They allow you to stop execution at any statement in your code. By doing this you can examine values in your variables, look at call stack, change values in variables [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/">Create Breakpoints With Hit Count In Visual Studio 2008</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This post shows you how to use Breakpoints in Visual Studio with a hit count. Breakpoints can be described as bread and butter of debugging. They allow you to stop execution at any statement in your code. By doing this you can examine values in your variables, look at call stack, change values in variables and much more.&#160; </p>
<p>Let’s follow this post with an example of a simple program which uses a loop to add a number to a List&lt;int&gt;.</p>
<pre class="code"><span style="color: blue">static void </span>Main(<span style="color: blue">string</span>[] args)
{
<span style="color: #2b91af">  List</span>&lt;<span style="color: blue">int</span>&gt; numbers = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: blue">int</span>&gt;();
<span style="color: blue">  for </span>(<span style="color: blue">int </span>i = 0; i &lt; 100; i++)
  {
    numbers.Add(i);
  }
}</pre>
<pre class="code">&#160;</pre>
<p>We will now add a breakpoint to numbers.Add(i) line. A breakpoint can be added by clicking on gray area on the left side of code editor or by pressing F9. </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Breakpoint" border="0" alt="Visual Studio Breakpoint" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image.png" width="403" height="146" /> </p>
<p>Here we have added a simple breakpoint. Our program will break when we hit the breakpoint for the first time. Let’s say that we want our breakpoint to hit at 50 iteration of our loop. To do this we can right click on the breakpoint circle on left hand side and click Hit Count.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Breakpoint" border="0" alt="Visual Studio Breakpoint" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image1.png" width="413" height="259" />&#160; </p>
<p>When we click on Hit Count we get a dialog where we can set the conditions when our breakpoint should be hit.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Breakpoint" border="0" alt="Visual Studio Breakpoint" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image2.png" width="516" height="253" /> </p>
<p>In our case we will select “break when the hit count is equal to” and enter 50.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Breakpoint" border="0" alt="Visual Studio Breakpoint" src="http://www.onedotnetway.com/wp-content/uploads/2009/10/image3.png" width="508" height="247" /> </p>
<p>If we now run our program we will hit the breakpoint when value of i = 49. Remember that we started i at 0 so when i is equal to 49 we are on the 50th iteration.</p>
<p>This comes in handy when debugging large loops and we are only interested in breaking when we have processed X number of iterations.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/">Create Breakpoints With Hit Count In Visual Studio 2008</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/create-breakpoints-with-hit-count-in-visual-studio-2008/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Output DOCTYPE In XSLT</title>
		<link>http://www.onedotnetway.com/output-doctype-in-xslt/</link>
		<comments>http://www.onedotnetway.com/output-doctype-in-xslt/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 03:18:37 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/output-doctype-in-xslt/</guid>
		<description><![CDATA[These days I am working on a personal project which I call “my precious”. This projects involves transforming XML documents into HTML using XSLT. Things were going smooth till I decided to output DOCTYPE from XSLT. This is what I did.
&#160;&#160; 
XSLT parser does not like the code above and gives me this error.
 
After [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/output-doctype-in-xslt/">Output DOCTYPE In XSLT</a></p>
]]></description>
			<content:encoded><![CDATA[<p>These days I am working on a personal project which I call “my precious”. This projects involves transforming XML documents into HTML using XSLT. Things were going smooth till I decided to output DOCTYPE from XSLT. This is what I did.</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="XSLT" border="0" alt="XSLT" src="http://www.onedotnetway.com/wp-content/uploads/2009/09/image2.png" width="457" height="80" />&#160; </p>
<p>XSLT parser does not like the code above and gives me this error.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="XSLT" border="0" alt="XSLT" src="http://www.onedotnetway.com/wp-content/uploads/2009/09/image3.png" width="404" height="56" /> </p>
<p>After scratching my head for a while and navigating through intellisense few times I found the right solution. The way to output DOCTYPE in XSLT is by placing in inside a CDATA. The following code works like a charm.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="XSLT" border="0" alt="XSLT" src="http://www.onedotnetway.com/wp-content/uploads/2009/09/image4.png" width="475" height="74" /> </p>
<p>This I thought was worth sharing.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/output-doctype-in-xslt/">Output DOCTYPE In XSLT</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/output-doctype-in-xslt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Output To Console In Windows Forms Application</title>
		<link>http://www.onedotnetway.com/output-to-console-in-windows-forms-application/</link>
		<comments>http://www.onedotnetway.com/output-to-console-in-windows-forms-application/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 01:25:27 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/output-to-console-in-windows-forms-application/</guid>
		<description><![CDATA[This post shows you how to output data to a Console in a Windows Forms Application. I use this technique religiously when developing Windows Forms applications. Debugging is much simpler when you can see information on what your application is doing in a Console. Of course the onus is on you as developer to output [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/output-to-console-in-windows-forms-application/">Output To Console In Windows Forms Application</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This post shows you how to output data to a Console in a Windows Forms Application. I use this technique religiously when developing Windows Forms applications. Debugging is much simpler when you can see information on what your application is doing in a Console. Of course the onus is on you as developer to output data which will help you.</p>
<p>In this post I will use a simple Windows Forms application which adds two numbers.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Windows Forms" src="http://www.onedotnetway.com/wp-content/uploads/2009/09/image.png" border="0" alt="Windows Forms" width="300" height="188" /></p>
<p>By default a Windows Forms application does not output to a Console even if you write a Console.Write() or Console.WriteLine(). This shortcoming can be addressed by using Win32 API. In your Windows Forms application you can declare a class which provides a wrapper around Win32 functions.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">Win32
</span>{
<span style="color: gray">  /// &lt;summary&gt;
  /// </span><span style="color: green">Allocates a new console for current process.
</span><span style="color: gray">  /// &lt;/summary&gt;
  </span>[<span style="color: #2b91af">DllImport</span>(<span style="color: #a31515">"kernel32.dll"</span>)]
<span style="color: blue">  public static extern </span><span style="color: #2b91af">Boolean </span>AllocConsole();

<span style="color: gray">  /// &lt;summary&gt;
  /// </span><span style="color: green">Frees the console.
</span><span style="color: gray">  /// &lt;/summary&gt;
  </span>[<span style="color: #2b91af">DllImport</span>(<span style="color: #a31515">"kernel32.dll"</span>)]
<span style="color: blue">  public static extern </span><span style="color: #2b91af">Boolean </span>FreeConsole();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>A Console must be started to accept input and display our messages. This can be done by calling Win32.AllocConsole() function. For my example I will start the console in my form’s constructor.</p>
<pre class="code"><span style="color: blue">public </span>Form1()
{
  InitializeComponent();

<span style="color: #2b91af">  Win32</span>.AllocConsole();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now when I write to Console, I will see data appear in the console window which was started in my constructor.</p>
<pre class="code"><span style="color: blue">private void </span>Add(<span style="color: blue">int </span>num1, <span style="color: blue">int </span>num2)
{
<span style="color: blue">  int </span>result = num1 + num2;

<span style="color: #2b91af">  Console</span>.WriteLine(
<span style="color: blue">    string</span>.Format(<span style="color: #a31515">"{0} + {1} = {2}"</span>, num1, num2, result));
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Console" src="http://www.onedotnetway.com/wp-content/uploads/2009/09/image1.png" border="0" alt="Console" width="419" height="189" /></p>
<p>As a good practice you should also close the console window by calling Win32.FreeConsole() method before your application exits.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/output-to-console-in-windows-forms-application/">Output To Console In Windows Forms Application</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/output-to-console-in-windows-forms-application/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ADO.NET Data Services Logical Operators</title>
		<link>http://www.onedotnetway.com/adonet-data-services-logical-operators/</link>
		<comments>http://www.onedotnetway.com/adonet-data-services-logical-operators/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 07:52:54 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Data Services]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/adonet-data-services-logical-operators/</guid>
		<description><![CDATA[In this post we will look at Logical Operators in ADO.NET Data Services. These operators can be used as filter expressions in our requests and ADO.NET Data Services applies the filter before results are returned. We will use Data Services generated over Adventureworks Lite database. If you are new to ADO.NET Data Services and would [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/adonet-data-services-logical-operators/">ADO.NET Data Services Logical Operators</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In this post we will look at Logical Operators in ADO.NET Data Services. These operators can be used as filter expressions in our requests and ADO.NET Data Services applies the filter before results are returned. We will use Data Services generated over Adventureworks Lite database. If you are new to ADO.NET Data Services and would like to know how to generate ADO.NET Data Service then please see this <a href="http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/">article</a>.</p>
<p>One thing to keep in mind is that filter expressions are case sensitive. And the syntax of applying filters in ADO.NET Data Services is</p>
<p><font color="#008000">&lt;url&gt;?$filter=&lt;your filter&gt;</font></p>
<p>Let’s now look at all logical operators</p>
<h3>Equal To</h3>
<p><font color="#008000">Parameter: eq</font></p>
<p>Equal To evaluates true when both operands have the same value. Here I am retrieving products where the value of Color matches “Yellow”.</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=Color eq &#8216;Yellow&#8217;</font></p>
<p>Logical operator can also be applied in code through a LINQ query. </p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>p.Color == <span style="color: #a31515">&quot;Yellow&quot;
</span><span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.Color);
}</pre>
<p>&#160;</p>
<h3>Not Equal To</h3>
<p><font color="#008000"></font></p>
<p><font color="#008000">Parameter: ne</font></p>
<p>Not equal is opposite of equal to and evaluates true when both operands do not have the same value. Here I am retrieving products where the value of Color is NOT “Yellow”.</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=Color ne &#8216;Yellow&#8217;</font></p>
<p>Following code will also achieve the same result through a LINQ query.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>p.Color != <span style="color: #a31515">&quot;Yellow&quot;
</span><span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.Color);
}</pre>
<p>&#160;</p>
<h3>Less than</h3>
<p><font color="#008000">Parameter: lt</font></p>
<p>Less than evaluates true when first operand is less than second. In this example I get all products where ListPrice is less than 20.</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=ListPrice lt 20</font></p>
<p>Here is the C# version of Less than operator.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>p.ListPrice &lt; 20
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>Less than or equal to</h3>
<p><font color="#008000">Parameter: le</font></p>
<p>Less than or equal to evaluates true when first operand is either less than or equal to second operand. In this example I am retrieving all products where ListPrice is less than or equal to 9.5</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=ListPrice le 9.5</font></p>
<p>And C# equivalent will look like this.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>p.ListPrice &lt;= 9.5m
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>Greater than</h3>
<p><font color="#008000">Parameter: gt</font></p>
<p>Greater than evaluates true if the first operand is greater than the second. In this example I am retrieving all products where ListPrice is greater than 9.5</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=ListPrice gt 9.5</font></p>
<p>Greater than is a no brainer with a LINQ query.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  here </span>p.ListPrice &gt; 9.5m
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>Greater than or equal to</h3>
<p><font color="#008000">Parameter: ge</font></p>
<p>Greater than or equal to evaluates true if the first operand is greater than or equal to second. Here is&#160; an example. I am retrieving all products where ListPrice is greater than or equal to 9.5</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=ListPrice ge 9.5</font></p>
<p>C# example</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>p.ListPrice &gt;= 9.5m
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.ProductID + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<h3>And</h3>
<p><font color="#008000">Parameter: and</font></p>
<p>“And” evaluates true when both operands are true. In this example I am retrieving all products where the Color is Black and ListPrice is greater than 1000.</p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=(Color eq &#8216;Black&#8217;) and (ListPrice gt 1000)</font></p>
<p>Same results can be retrieved in C# with this code.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>(p.Color == <span style="color: #a31515">&quot;Black&quot;</span>)
    &amp;&amp; (p.ListPrice &gt; 1000)
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.Color + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p>&#160;</p>
<h3>Or</h3>
<p><font color="#008000">Parameter: or</font></p>
<p>“Or” evaluates true when either operand is true. In this example I am retrieving all products where either the Color is Black or ListPrice is greater than 1000.</p>
<p><a href="http://localhost:6803/DataService.svc/Product?"><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?</font></a><font color="#800000" size="3">$filter=(Color eq &#8216;Black&#8217;) or (ListPrice gt 1000)</font></p>
<p>Now with C#.</p>
<pre class="code"><span style="color: #2b91af">AdventureWorksEntities </span>context = <span style="color: blue">new </span><span style="color: #2b91af">AdventureWorksEntities</span>(uri);
<span style="color: #2b91af">DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products = context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">@&quot;/Product&quot;</span>);

<span style="color: blue">var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">  where </span>(p.Color == <span style="color: #a31515">&quot;Black&quot;</span>)
    || (p.ListPrice &gt; 1000)
<span style="color: blue">  select </span>p;

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>query)
{
<span style="color: #2b91af">  Console</span>.WriteLine(item.Color + <span style="color: #a31515">&quot;\t&quot; </span>+ item.ListPrice);
}</pre>
<p>&#160;</p>
<h3>Not</h3>
<p><font color="#008000">Parameter: not</font></p>
<p>“Not” evaluates true if operand is false. An example can be retrieving all products where the Color is not Black. </p>
<p><font color="#800000" size="3">http://localhost:6803/DataService.svc/Product?$filter=not (Color eq &#8216;Black&#8217;)</font></p>
<p>While this can be achieved using not equal to operator they are not the same. I’ll leave C# code for this one for you :)</p>
<p>&#160;</p>
<h3>Conclusion</h3>
<p>This article demonstrated all logical operators available for ADO.NET Data Services. In a future post I will cover other types of operators for ADO.NET Data Services. </p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/adonet-data-services-logical-operators/">ADO.NET Data Services Logical Operators</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/adonet-data-services-logical-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Execute Stored Procedure With ADO.NET Data Services</title>
		<link>http://www.onedotnetway.com/execute-stored-procedure-with-adonet-data-services/</link>
		<comments>http://www.onedotnetway.com/execute-stored-procedure-with-adonet-data-services/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 10:21:10 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Data Services]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/?p=666</guid>
		<description><![CDATA[Introduction
In an earlier article I looked at how DO.NET Data Services can be used with ASP.NET. In this post I will talk about using ADO.NET Data Services to retrieve data via SQL Server stored procedure. Doing this is simple and I will follow a similar approach to hook everything up as I did in my [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/execute-stored-procedure-with-adonet-data-services/">Execute Stored Procedure With ADO.NET Data Services</a></p>
]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>In an <a href="http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/">earlier article</a> I looked at how DO.NET Data Services can be used with ASP.NET. In this post I will talk about using ADO.NET Data Services to retrieve data via SQL Server stored procedure. Doing this is simple and I will follow a similar approach to hook everything up as I did in my <a href="http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/">earlier post</a>.</p>
<p>I have created a stored procedure which retrieves data from Employees table in Northwind database based on city name. Here is the script I used to create the procedure.</p>
<pre class="code"><span style="color: blue">CREATE PROCEDURE </span>[dbo]<span style="color: gray">.</span>[GetEmployeesByCity] 

    @City <span style="color: blue">NVARCHAR</span><span style="color: gray">(</span>15<span style="color: gray">)
</span><span style="color: blue">AS

BEGIN

    SELECT </span><span style="color: gray">*
    </span><span style="color: blue">FROM </span>Employees
    <span style="color: blue">WHERE </span>City <span style="color: gray">= </span>@City

<span style="color: blue">END</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<h3>Creating Data Model</h3>
<p>ADO.NET Data Services sits between the client and a data source, so the first thing I’ll need is a data source. I will use Entity Framework to create my data source.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image13.png" border="0" alt="image" width="544" height="427" /></p>
<p>To make things simple I will select Employees table only for my Entity Data Model.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image14.png" border="0" alt="image" width="544" height="483" /></p>
<h3>Mapping Stored Procedure in EDM</h3>
<p>My objective here is to retrieve data from a stored procedure. To this I need to expose the procedure through my data layer which I have created using Entity Framework. Mapping a stored procedure in Entity Framework can be done by following these steps.</p>
<p>Open Model Browser (View –&gt; Other Windows –&gt; Model Browser). Right click on Stored Prodecures under NorthwindModel.Store and click Update Model from Database.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image6.png" border="0" alt="image" width="380" height="208" /></p>
<p>Select the stored procedure (GetEmployeesByCity in this case) and click Finish.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image7.png" border="0" alt="image" width="307" height="309" /></p>
<p>Go back to Model Browser and under stored procedure right click the stored procedure and click Create Function Import.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image8.png" border="0" alt="image" width="411" height="250" /></p>
<p>Select Employees entity as the return type and click OK.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image9.png" border="0" alt="image" width="399" height="291" /></p>
<p>Entity Model is now setup to execute the stored procedure and return results. It can be called like this.</p>
<pre class="code"><span style="color: #2b91af">NorthwindEntities </span>entities = <span style="color: blue">new </span><span style="color: #2b91af">NorthwindEntities</span>();
<span style="color: blue">var </span>employees = entities.GetEmployeesByCity(<span style="color: #a31515">"London"</span>);</pre>
<p>My goal however is to retrieve data via ADO.NET Data Services so I’ll start creating my service.</p>
<h3>And Now With a Service</h3>
<p>Because I’d like to access this data through my ADO.NET Data Service so the first thing I’ll do is create a service called NorthwindEmployeeService. I will add a new item to my project of type ADO.NET Data Service.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image10.png" border="0" alt="image" width="540" height="400" /></p>
<p>Visual Studio creates a blank service with some scaffolding for me to get started. First thing I need to do is let my service know about my data source class and then configure appropriate rights to my entities and operations. To be simple I will just allow everything. Below is the code for my service after making changes.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">NorthwindEmployeeService </span>: <span style="color: #2b91af">DataService</span>&lt;<span style="color: #2b91af">NorthwindEntities</span>&gt;
{
<span style="color: green">  // This method is called only once to initialize service-wide policies.
</span><span style="color: blue">  public static void </span>InitializeService(<span style="color: #2b91af">IDataServiceConfiguration </span>config)
  {
    config.SetEntitySetAccessRule(<span style="color: #a31515">"*"</span>, <span style="color: #2b91af">EntitySetRights</span>.AllRead);
    config.SetServiceOperationAccessRule(<span style="color: #a31515">"*"</span>, <span style="color: #2b91af">ServiceOperationRights</span>.All);
  }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>By default my service does not know that it should also work with a stored procedure. To do this i can write a method which will execute the procedure and return results. Such a method can look like this.</p>
<pre class="code">[<span style="color: #2b91af">WebGet</span>]
<span style="color: blue">public </span><span style="color: #2b91af">ObjectResult</span>&lt;<span style="color: #2b91af">Employees</span>&gt; GetEmployeesByCity(<span style="color: blue">string </span>cityName)
{
<span style="color: #2b91af">  NorthwindEntities </span>entities = <span style="color: blue">new </span><span style="color: #2b91af">NorthwindEntities</span>();
<span style="color: blue">  return </span>entities.GetEmployeesByCity(cityName);
}</pre>
<p>Method above tells the service to expose a GetEmployeesByCity method which can be called by clients. Note that the method is decorated with a WebGet attribute which indicates that this is a GET method which can be called by a web client.</p>
<h3>Running Service and Calling Stored Procedure</h3>
<p>To see my service in action I can hit F5</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image11.png" border="0" alt="image" width="540" height="500" /></p>
<p>To see the results from the stored procedure I can use the following URL.</p>
<p><span style="color: #800000; font-size: x-small;">http://localhost:16147/NorthwindEmployeeService.svc/GetEmployeesByCity?cityName=&#8217;London&#8217;</span></p>
<p>Here I am passing in the parameter as a query string which is accepted by my service and appropriate results are returned.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/08/image12.png" border="0" alt="image" width="539" height="645" /></p>
<h3>Conclusion</h3>
<p>In this article I used ADO.NET Data Services to execute a stored procedure and return results. I am not in favour of implementing a direct mapping between services and database and the design can be a little better whereby data layer can be sensibly abstracted away by service. However the idea was to demonstrate a concept. I hope you enjoyed reading this article.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/execute-stored-procedure-with-adonet-data-services/">Execute Stored Procedure With ADO.NET Data Services</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/execute-stored-procedure-with-adonet-data-services/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ADO.NET Data Services With ASP.NET</title>
		<link>http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/</link>
		<comments>http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 12:27:10 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Data Services]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/adonet-data-services-tutorial-with-linq-to-sql-and-aspnet/</guid>
		<description><![CDATA[Introduction
In this tutorial we will look at how ADO.NET Data Services can be used to create services which are consumed by ASP.NET client. We will use Adventure works Lite database as an example to demonstrate the concepts. Code for this article can be downloaded at the bottom of the article.
ADO.NET Data Services as the name [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/">ADO.NET Data Services With ASP.NET</a></p>
]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>In this tutorial we will look at how ADO.NET Data Services can be used to create services which are consumed by ASP.NET client. We will use Adventure works Lite database as an example to demonstrate the concepts. Code for this article can be downloaded at the bottom of the article.</p>
<p>ADO.NET Data Services as the name says is a services layer between your application and an underlying data source. It uses REST principals to access and persist information to and from the data source. Services layer itself can be created very easily. Most of the work is done by  Visual Studio for you.</p>
<p>In this tutorial we will build an application for AdventureWorks Lite database. We will build a page which let’s a user browse through products. The reason for picking up AdventureWorks Lite as an example is so that we can work with a variety of data including images. If you do not have AdventureWorks Lite then you can download it <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=SqlServerSamples">here</a>. For our application we will work with this data model</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image46.png" border="0" alt="image" width="540" height="406" /></p>
<h3>Creating Service</h3>
<p>Creating a ADO.NET Data Service in Visual Studio is a no brainer. All we need to do is add a new item of type ADO.NET Data Service, give it an appropriate name and we are done.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image47.png" border="0" alt="image" width="540" height="432" /></p>
<p>Our ADO.NET Service will interact with some kind of data source and Entity Framework perfectly fits that purpose. We now need to create a EDM (Entity Data Model) which includes tables we want to interact with via our services. If you never worked with Entity Framework then <a href="http://msdn.microsoft.com/en-us/library/bb399182.aspx">this quickstart</a> will get you going.</p>
<p>By creating a service and our Entity Data Model we have put together two major components of our solution. Before we can hit F5 to see our service running, there are few things we need to put in place. We must tell our service that there is a Data Layer that we want it to use. Now all ADO.NET Data Services inherit from DataService&lt;T&gt; which can be found in System.Data.Services namespace. The code produced by Visual Studio for our service leaves a placeholder for &lt;T&gt; with a comment. All we need to do is specify the correct type. Our class declaration for our service should look like this.</p>
<pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">AdventureWorksService </span>: <span style="color: #2b91af">DataService</span>&lt;<span style="color: #2b91af">AdventureWorksEntities</span>&gt;</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here we have established integration between our service and our data source. Next thing we need to do is configure appropriate access levels for our service and its operations. Code below when executed initializes our service to have all possible access over all entities defined in our EDM and all access over all operations. Note the asterix, basically we are saying here that include all Entity Sets and all operations.</p>
<pre class="code"><span style="color: blue">public static void </span>InitializeService(<span style="color: #2b91af">IDataServiceConfiguration </span>config)
{
  config.SetEntitySetAccessRule(<span style="color: #a31515">"*"</span>, <span style="color: #2b91af">EntitySetRights</span>.All);
  config.SetServiceOperationAccessRule(<span style="color: #a31515">"*"</span>, <span style="color: #2b91af">ServiceOperationRights</span>.All);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>We are now ready to go and hit F5. If we set AdventureWorksService.svc as a start page and run our project we can see our service running. Now that we have our service running, we will start building our ASP.NET pages which will query our service, receive and display data.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image48.png" border="0" alt="image" width="540" height="597" /></p>
<h3>Creating Proxy Objects</h3>
<p>Our ASP.NET application will need to access the service through a proxy. Creating a proxy is very easy. After making sure that our service is running, we need to add a service reference to our serivce. This can be done this way.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image49.png" border="0" alt="image" width="540" height="434" /></p>
<p>It is also a good idea to change the Namespace from ServiceReference1 to AdventureWorksService.</p>
<h3>Creating Web Page To Display Data</h3>
<p>We can now make calls to our service and retrieve data. First thing we need to do is load data from ProductCategory and bind it to a dropdown. But before that let’s have a look at what we will produce.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image50.png" border="0" alt="image" width="540" height="521" /></p>
<p>Getting back to binding our dropdown control. We should write a query which calls our service which in turns fetches data from database and delivers to us. One good thing about ADO.NET Data Services is that you can write LINQ queries with it. ADO.NET Data Services comes with a LINQ provider popularly known as LINQ To REST.  Without LINQ support ADO.NET Data Services will be just too complicated and IMO useless. However LINQ support is limited. Here are things you cannot do:</p>
<ol>
<li>You cannot write queries which involve joins or sub queries.</li>
<li>You cannot create anonymous types in your queries.</li>
<li>Aggregates such as Count, Min, Max are not available.</li>
<li>There is no GroupBy support available.</li>
</ol>
<p>Besides the list of can’t do above, LINQ To REST still makes working with ADO.NET Data Services much easier than otherwise. Following code will make a service call and bind our drop down.</p>
<pre class="code"><span style="color: blue">private void </span>BindProductCategories()
{
<span style="color: #2b91af">  DataServiceQuery</span>&lt;<span style="color: #2b91af">ProductCategory</span>&gt; productCategories =
    context.CreateQuery&lt;<span style="color: #2b91af">ProductCategory</span>&gt;(<span style="color: #a31515">"/ProductCategory"</span>);

<span style="color: blue">  var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>productCategories
<span style="color: blue">    orderby </span>p.Name
<span style="color: blue">    select </span>p;

  ddlProductCategory.DataSource = query;
  ddlProductCategory.DataBind();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>We’d also like to refresh data in our grid when the user selects another category. This is done by BindProductsGrid method.</p>
<pre class="code"><span style="color: blue">private void </span>BindProductsGrid()
{
<span style="color: blue">  int </span>productCategoryID = <span style="color: #2b91af">Convert</span>.ToInt32(ddlProductCategory.SelectedValue);

<span style="color: #2b91af">  DataServiceQuery</span>&lt;<span style="color: #2b91af">Product</span>&gt; products =
    context.CreateQuery&lt;<span style="color: #2b91af">Product</span>&gt;(<span style="color: #a31515">"/Product"</span>);

<span style="color: blue">  var </span>query = <span style="color: blue">from </span>p <span style="color: blue">in </span>products
<span style="color: blue">    where </span>p.ProductCategory.ProductCategoryID == productCategoryID
<span style="color: blue">    select </span>p;

  gdvProducts.DataSource = query;
  gdvProducts.DataBind();
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The way I bind the image is by using another page which just does Response.BinaryWrite.  Here is the markup of default.aspx page which is the entire UI. You can play with it by downloading the entire solution. The markup is here just to make the post look good ;)</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">form </span><span style="color: red">id</span><span style="color: blue">="form1" </span><span style="color: red">runat</span><span style="color: blue">="server"&gt;
  &lt;</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
</span>      Product Category
<span style="color: blue">      &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">DropDownList </span><span style="color: red">ID</span><span style="color: blue">="ddlProductCategory" </span><span style="color: red">runat</span><span style="color: blue">="server"
</span><span style="color: red">        DataValueField</span><span style="color: blue">="ProductCategoryID"
</span><span style="color: red">        AutoPostBack</span><span style="color: blue">="true"
</span><span style="color: red">        DataTextField</span><span style="color: blue">="Name"
</span><span style="color: red">        OnSelectedIndexChanged</span><span style="color: blue">="ddlProductCategory_SelectedIndexChanged"&gt;
      &lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">DropDownList</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;
</span>    Products
<span style="color: blue">    &lt;</span><span style="color: #a31515">br </span><span style="color: blue">/&gt;
    &lt;</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">GridView </span><span style="color: red">ID</span><span style="color: blue">="gdvProducts" </span><span style="color: red">runat</span><span style="color: blue">="server"
</span><span style="color: red">        CssClass</span><span style="color: blue">="sample"
</span><span style="color: red">        Width</span><span style="color: blue">="600px"
</span><span style="color: red">        AutoGenerateColumns</span><span style="color: blue">="false"
</span><span style="color: red">        OnRowCreated</span><span style="color: blue">="gdvProducts_RowCreated"&gt;
        &lt;</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;
          &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField </span><span style="color: red">DataField</span><span style="color: blue">="ProductNumber" </span><span style="color: red">HeaderText</span><span style="color: blue">="Number" /&gt;
          &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">BoundField </span><span style="color: red">DataField</span><span style="color: blue">="Name" </span><span style="color: red">HeaderText</span><span style="color: blue">="Name" /&gt;
          &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span><span style="color: blue">&gt;
            &lt;</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;
              &lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">Image </span><span style="color: red">ID</span><span style="color: blue">="Image1" </span><span style="color: red">runat</span><span style="color: blue">="server" </span><span style="color: red">ImageUrl</span><span style="color: blue">='ImageHelper.aspx' /&gt;
            &lt;/</span><span style="color: #a31515">ItemTemplate</span><span style="color: blue">&gt;
          &lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">TemplateField</span><span style="color: blue">&gt;
        &lt;/</span><span style="color: #a31515">Columns</span><span style="color: blue">&gt;
      &lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">GridView</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
</span><span style="color: blue">  &lt;/</span><span style="color: #a31515">div</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">form</span><span style="color: blue">&gt;</span></pre>
<h3>Conclusion</h3>
<p>This was a brief introduction to ADO.NET Data Services. We looked at how to create a service and consume it in a ASP.NET website. We also looked at some limitations of LINQ provider used by ADO.NET Data Services. In future posts I will talk about other features of ADO.NET Data Services.</p>
<h3>Download Code For This Article</h3>
<p><strong><span style="color: #0000ff; font-size: medium"><a href="http://www.onedotnetway.com/wp-content/plugins/download-monitor/download.php?id=adonetdataservices.zip" title="Downloaded 590 times">ADONETDataServices Sample Code Size 84.72 KB</a></span></strong></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/">ADO.NET Data Services With ASP.NET</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/adonet-data-services-tutorial-with-aspnet/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Get URI Of Silverlight Plugin Host Page</title>
		<link>http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/</link>
		<comments>http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:05:58 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/</guid>
		<description><![CDATA[Within our Silverlight application if we want to know the URI where our Silverlight content is running, we can tap into System.Windows.Browser namespace. This namespace contains object which are full of Browser related information. This is an example of retrieving the URI from within Silverlight application.
&#60;StackPanel x:Name=&#34;LayoutRoot&#34; Margin=&#34;10&#34;&#62;
  &#60;TextBlock Text=&#34;Your URL is: &#34; /&#62;
 [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/">Get URI Of Silverlight Plugin Host Page</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Within our Silverlight application if we want to know the URI where our Silverlight content is running, we can tap into System.Windows.Browser namespace. This namespace contains object which are full of Browser related information. This is an example of retrieving the URI from within Silverlight application.</p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;LayoutRoot&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;10&quot;&gt;
  &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;Your URL is: &quot; /&gt;
  &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">AbsoluteUri</span><span style="color: blue">}&quot; /&gt;
&lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>In our C# code we can set the DataContext so that the second TextBlock above displays the information we desire.</p>
<pre class="code"><span style="color: blue">private void </span>UserControl_Loaded(<span style="color: blue">object </span>sender, <span style="color: #2b91af">RoutedEventArgs </span>e)
{
  LayoutRoot.DataContext =
    System.Windows.Browser.<span style="color: #2b91af">HtmlPage</span>.Document.DocumentUri;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Here is my output which displays the URL at which my Silverlight plugin is hosted. </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image18.png" width="240" height="46" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/">Get URI Of Silverlight Plugin Host Page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-uri-of-silverlight-plugin-host-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 3 Element To Element Binding</title>
		<link>http://www.onedotnetway.com/silverlight-3-element-to-element-binding/</link>
		<comments>http://www.onedotnetway.com/silverlight-3-element-to-element-binding/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 02:33:41 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/silverlight-3-element-to-element-binding/</guid>
		<description><![CDATA[Silverlight 3 among its other features includes element to element binding. This was always available in WPF but somehow missing in Silverlight 1 and 2. And now Silverlight 3 has bridged that gap. Element to element binding can reduce code when used properly. In this post I will show you how to use this feature.
Example
In [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/silverlight-3-element-to-element-binding/">Silverlight 3 Element To Element Binding</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Silverlight 3 among its other features includes element to element binding. This was always available in WPF but somehow missing in Silverlight 1 and 2. And now Silverlight 3 has bridged that gap. Element to element binding can reduce code when used properly. In this post I will show you how to use this feature.</p>
<h3>Example</h3>
<p>In this very basic example I will use two controls, a TextBlock and a Slider. When the slider is moved, the value in TextBlock changes accordingly. </p>
<pre class="code"><span style="color: blue">&lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">="LayoutRoot"&gt;
  &lt;</span><span style="color: #a31515">TextBlock
</span><span style="color: red">    Width</span><span style="color: blue">="100"
</span><span style="color: red">    Foreground</span><span style="color: blue">="Blue"
</span><span style="color: red">    HorizontalAlignment</span><span style="color: blue">="Center"
</span><span style="color: red">    Text</span><span style="color: blue">="{</span><span style="color: #a31515">Binding </span><span style="color: red">Value</span><span style="color: blue">, </span><span style="color: red">ElementName</span><span style="color: blue">=slider1}" /&gt;
  &lt;</span><span style="color: #a31515">Slider
</span><span style="color: red">    x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">="slider1"
</span><span style="color: red">    Minimum</span><span style="color: blue">="0"
</span><span style="color: red">    Maximum</span><span style="color: blue">="100"
</span><span style="color: red">    Width</span><span style="color: blue">="200" /&gt;
&lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a>
<pre class="code">&nbsp;</pre>
<p>Here is a screenshot of the output produced by XAML above.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Element Binding" border="0" alt="Element Binding" src="http://www.onedotnetway.com/wp-content/uploads/2009/07/image17.png" width="207" height="39">&nbsp;</p>
<p>Element binding can come in very handy in certain scenarios. An example can be making all fields read-only based on a status flag. Rather than writing C# code, this can be done easily and cleanly with element binding.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/silverlight-3-element-to-element-binding/">Silverlight 3 Element To Element Binding</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/silverlight-3-element-to-element-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
