<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>A.I on the 1s and 0s</title><link>http://weblogs.asp.net/alnurismail/default.aspx</link><description>Alnur Ismail is a PM for Microsoft's XAML</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Time For a Change</title><link>http://weblogs.asp.net/alnurismail/archive/2011/11/04/time-for-a-change.aspx</link><pubDate>Fri, 04 Nov 2011 17:53:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:8032478</guid><dc:creator>alnurismail</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=8032478</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2011/11/04/time-for-a-change.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;This blog has moved to &lt;A href="http://alnurismail.com/"&gt;http://alnurismail.com&lt;/A&gt;. All the posts have been migrated over.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Thanks,&lt;BR&gt;Alnur&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8032478" width="1" height="1"&gt;</description></item><item><title>//BUILD</title><link>http://weblogs.asp.net/alnurismail/archive/2011/09/12/build.aspx</link><pubDate>Mon, 12 Sep 2011 14:37:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7949872</guid><dc:creator>alnurismail</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7949872</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2011/09/12/build.aspx#comments</comments><description>&lt;P&gt;Finally the time has come to talk. The vow of silence is over and it’ll feel so good to share what we’ve all been working extremely (work-life balance FAIL) hard on! I’m waiting for the cab to pull up so I can catch the flight to Anaheim. Recently it was made public that XAML is part of Windows 8 – come Tuesday all will be revealed..&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[Update]&lt;/STRONG&gt; - The keynote was awesome and we already heard some great feedback on what XAML offers developers. Here are some links that I posted on twitter (@alnurismail) earlier today:&lt;/P&gt;
&lt;P&gt;1) List of XAML sessions this week: &lt;A href="http://timheuer.com/blog/archive/2011/09/13/xaml-sessions-at-build.aspx" mce_href="http://timheuer.com/blog/archive/2011/09/13/xaml-sessions-at-build.aspx"&gt;http://timheuer.com/blog/archive/2011/09/13/xaml-sessions-at-build.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2) Get Windows 8 Developer Preview from: &lt;A title=http://msdn.microsoft.com/en-us/windows/home/ class=twitter-timeline-link href="http://dev.windows.com/" rel=nofollow target=_blank mce_href="http://dev.windows.com/" data-display-url="dev.windows.com" data-ultimate-url="http://msdn.microsoft.com/en-us/windows/home/" data-expanded-url="http://dev.windows.com"&gt;http://dev.windows.com&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;3) Windows 8 code samples (covers the WinRT API surface) at: &lt;A title=http://code.msdn.microsoft.com/windowsapps/ class=twitter-timeline-link href="http://t.co/lPxakSN" rel=nofollow target=_blank mce_href="http://t.co/lPxakSN" data-display-url="code.msdn.microsoft.com/windowsapps" data-ultimate-url="http://code.msdn.microsoft.com/windowsapps/" data-expanded-url="http://code.msdn.microsoft.com/windowsapps"&gt;http://code.msdn.microsoft.com/windowsapps&lt;/A&gt; &lt;A title=#bldwin class="  twitter-hashtag pretty-link" href="http://twitter.com/#!/search?q=%23bldwin" rel=nofollow mce_href="http://twitter.com/#!/search?q=%23bldwin"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7949872" width="1" height="1"&gt;</description></item><item><title>Why I Love The Microsoft Web Platform (And How I Built an Enterprise Ready Site in 48hrs)</title><link>http://weblogs.asp.net/alnurismail/archive/2011/06/04/why-i-love-the-microsoft-web-platform-and-how-i-built-an-enterprise-ready-site-in-48hrs.aspx</link><pubDate>Sat, 04 Jun 2011 18:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7816821</guid><dc:creator>alnurismail</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7816821</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2011/06/04/why-i-love-the-microsoft-web-platform-and-how-i-built-an-enterprise-ready-site-in-48hrs.aspx#comments</comments><description>&lt;p&gt;There is no other web platform in the world that lets you build a fully functional, optimized, and scalable enterprise ready website in under 48hrs. Microsoft’s web platform provides you with a powerful set of tools, servers, and tech that can help you take an idea in your head and make it a reality within the blink of an eye. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Full Disclosure: &lt;/em&gt;&lt;/strong&gt;If it wasn’t clear by the blurb next to the paper clip in the top left I work for Microsoft. Moreover, I work in DevDiv and see &lt;a href="http://weblogs.asp.net/scottgu/" target="_blank" mce_href="http://weblogs.asp.net/scottgu/"&gt;Scott Gu&lt;/a&gt; in the halls everyday. However, this really is my unbiased &lt;em&gt;&lt;u&gt;personal opinion&lt;/u&gt;&lt;/em&gt; of the Microsoft Web Platform.To understand the reasons behind why I’m writing this post I need to give you some background. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Background        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;On a recent trip home to see family and friends I had the idea to create a 100% free dating website very similar to plentyoffish.com. Except, I decided to target it towards the Indian and non-resident Indian (NRI) audiences – I won’t bore you with why but if you’ve ever heard of Shaadi or BharatMatrimony then you know where this is going. I looked at my competition and designed a site in my head that would be able to compete with these juggernauts of Indian matrimony and dating. I called it Desi Spark (Desi means a person of Indian or Pakistani descent)&amp;nbsp; and wanted it to be the first professional 100% &lt;a title="free Indian matrimony and Indian dating" href="http://www.desispark.com/" target="_blank" mce_href="http://www.desispark.com/"&gt;free Indian matrimony and dating&lt;/a&gt; website.&lt;/p&gt;  &lt;p&gt;You can see the finished site &lt;a title="free Indian matrimony and Indian dating" href="http://www.desispark.com/" target="_blank" mce_href="http://www.desispark.com/"&gt;here&lt;/a&gt;. If you know any desis please send the link their way! &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png" mce_src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png"&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Reason For Writing        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;Now back to the reason why I’m writing this. Put simply, it’s because I’m absolutely amazed at the raw power and robustness of what we at Microsoft offer. When you use all the offerings in concert you just have to step back and admire the beauty. Moreover, I LOVE the fact that every tool (except two) I used to create Desi Spark was for free and from Microsoft. Even more, I could have signed up for &lt;a href="http://www.microsoft.com/bizspark/" target="_blank" mce_href="http://www.microsoft.com/bizspark/"&gt;BizSpark&lt;/a&gt; or &lt;a href="http://www.microsoft.com/web/websitespark/" target="_blank" mce_href="http://www.microsoft.com/web/websitespark/"&gt;WebsiteSpark&lt;/a&gt; and got immediate access to full-featured development tools! (If you’re a student check out &lt;a href="https://www.dreamspark.com/" target="_blank" mce_href="https://www.dreamspark.com/"&gt;DreamSpark&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;Seriously, who else but Microsoft offers this? &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;strong&gt;&lt;em&gt;Full Disclosure (A Little More): &lt;/em&gt;&lt;/strong&gt;        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;Before we talk shop about how I built my own enterprise ready website I want to give a little more disclosure on my background. If you follow my blog you’ll likely have seen that 1) I don’t post regularly &lt;img class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Smile with tongue out" src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smilewithtongueout_7B3FD331.png" mce_src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smilewithtongueout_7B3FD331.png"&gt; (more because of NDAs than anything else) and 2) I’m a big fan of ASP .NET, ASP .NET AJAX, and of course JQuery. I was a web dev for years before I turned PM so I’m pretty familiar with the technologies. &lt;/p&gt;  &lt;p&gt;I did create Desi Spark in approximately 48hrs but I’ve subtracted away all the countless hours of design, graphics, and testing I spent. That is a pure development cost. If you’re like me you know with a good design things just work. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Dude, It’s Easy To Create A Dating Site In 48hrs        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;Well it is with the Microsoft Web Platform &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png" mce_src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png"&gt;. No, but seriously, I hear ya. If this was a cookie cutter site I’d fess up but it isn’t. It was created for the demographics I’m targeting and consequently has a lot of cool features like:&lt;/p&gt;  &lt;ol&gt;   &lt;ol&gt;     &lt;li&gt;Custom profiles depending on a user’s intent (i.e. matrimony or dating) &lt;/li&gt;      &lt;li&gt;Photo album upload with built-in cropping tool &lt;/li&gt;      &lt;li&gt;Advanced Hotmail style messaging system        &lt;ol&gt;         &lt;ul&gt;           &lt;li&gt;message users &lt;/li&gt;            &lt;li&gt;see sent mail &lt;/li&gt;            &lt;li&gt;see who’s read or delete your messages &lt;/li&gt;            &lt;li&gt;print messages &lt;/li&gt;            &lt;li&gt;save messages &lt;/li&gt;            &lt;li&gt;message limits &lt;/li&gt;         &lt;/ul&gt; &lt;!--EndFragment--&gt;&lt;/ol&gt;     &lt;/li&gt;      &lt;li&gt;Ability to see who’s viewed your profile &lt;/li&gt;      &lt;li&gt;Advanced search that finds matches on over 20 different criteria &lt;/li&gt;      &lt;li&gt;Custom matching algorithm to find compatible users &lt;/li&gt;      &lt;li&gt;Favorites system with ratings that you can sort on &lt;/li&gt;      &lt;li&gt;Contact preferences to determine who’s allowed to message you (based on multiple levels of criteria) &lt;/li&gt;      &lt;li&gt;Block users &lt;/li&gt;      &lt;li&gt;Friend referral system &lt;/li&gt;      &lt;li&gt;… and more… I’m getting tired of typing them all but I’ve taken some screen shots below so you can check it out &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png" mce_src="http://weblogs.asp.net/blogs/alnurismail/wlEmoticon-smile_359B4913.png"&gt; &lt;/li&gt;   &lt;/ol&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/alnurismail/desispark1_7EDDEE0E.png" target="_blank" mce_href="http://weblogs.asp.net/blogs/alnurismail/desispark1_7EDDEE0E.png"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="desispark1" border="0" alt="desispark1" src="http://weblogs.asp.net/blogs/alnurismail/desispark1_thumb_433DDF4E.png" width="174" height="117" mce_src="http://weblogs.asp.net/blogs/alnurismail/desispark1_thumb_433DDF4E.png"&gt;&lt;/a&gt;&lt;a href="http://weblogs.asp.net/blogs/alnurismail/desispark2_224A6CA7.png" mce_href="http://weblogs.asp.net/blogs/alnurismail/desispark2_224A6CA7.png"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="desispark2" border="0" alt="desispark2" src="http://weblogs.asp.net/blogs/alnurismail/desispark2_thumb_00126121.png" width="174" height="116" mce_src="http://weblogs.asp.net/blogs/alnurismail/desispark2_thumb_00126121.png"&gt;&lt;/a&gt;&lt;a href="http://weblogs.asp.net/blogs/alnurismail/desispark3_2D274DEF.png" mce_href="http://weblogs.asp.net/blogs/alnurismail/desispark3_2D274DEF.png"&gt;&lt;img style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="desispark3" border="0" alt="desispark3" src="http://weblogs.asp.net/blogs/alnurismail/desispark3_thumb_127AB1D6.png" width="174" height="127" mce_src="http://weblogs.asp.net/blogs/alnurismail/desispark3_thumb_127AB1D6.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Platform        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;OK, let’s talk shop. It’s all HTML 5 – just kidding! Let me walk you through my stack, and then through the tools I used.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;The Framework      &lt;br&gt;&lt;/u&gt;I used &lt;a href="http://www.asp.net/" target="_blank" mce_href="http://www.asp.net/"&gt;ASP .NET&lt;/a&gt; which is free and has a rich set of features, integration with databases and makes web services a breeze (check out this &lt;a href="http://weblogs.asp.net/alnurismail/archive/2008/11/21/a.aspx" target="_blank" mce_href="http://weblogs.asp.net/alnurismail/archive/2008/11/21/a.aspx"&gt;post&lt;/a&gt; – a little dated but still enough to get you going). &lt;/p&gt;  &lt;p&gt;Throw on ASP .NET AJAX and all their amazing &lt;a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/" target="_blank" mce_href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/"&gt;rich controls&lt;/a&gt; and then add the &lt;a href="http://www.asp.net/ajaxlibrary/cdn.ashx" target="_blank" mce_href="http://www.asp.net/ajaxlibrary/cdn.ashx"&gt;Microsoft Ajax CDN&lt;/a&gt; to get &lt;a href="http://jquery.com/" target="_blank" mce_href="http://jquery.com/"&gt;JQuery&lt;/a&gt; (supported by Microsoft!) and &lt;a href="http://jqueryui.com/" target="_blank" mce_href="http://jqueryui.com/"&gt;JQuery UI&lt;/a&gt; and you’ve got an insane amount of UI power at your finger tips that all work seamlessly together. Don’t forget about jQuery &lt;a href="http://docs.jquery.com/Plugins/validation" target="_blank" mce_href="http://docs.jquery.com/Plugins/validation"&gt;validation&lt;/a&gt; for some slick client-side validation (but always always remember to validate on the server!).     &lt;br&gt;    &lt;br&gt;So we’ve got the UI covered; what about data? Piece of cake! Easily add data-driven functionality by using the robust data controls, LINQ and &lt;a href="http://msdn.microsoft.com/en-us/library/bb386976.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/bb386976.aspx"&gt;LINQ to SQL&lt;/a&gt;. You literally just drag and drop and your entire data model is built in less than 60 seconds. No more fussing with DataSets. If you don’t know SQL then use LINQ to query your database. You don’t even need to write stored procedures anymore thanks to LINQ – it’s equally secure and probably optimizes better (although I will admit I used sprocs for any complex queries like searching and the matching algorithm, but for any simple select/create/update/delete operation I used LINQ to SQL). &lt;/p&gt;  &lt;p&gt;We’re still not done. Finally, I used the &lt;a href="http://msdn.microsoft.com/en-us/library/ff632023.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/ff632023.aspx"&gt;Enterprise Library&lt;/a&gt; from Microsoft Patterns and Practices to implement all my exception handling and logging logic. Now I get emails when there is a P0 error, and everything else is logged to my database. Set up was simple thanks to the tools that it provides and all I had to do was implement a simple try/catch pattern to get the correct behavior.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;The Database      &lt;br&gt;&lt;/u&gt;On my local machine I installed &lt;a href="http://www.microsoft.com/express/Database/Default.aspx" target="_blank" mce_href="http://www.microsoft.com/express/Database/Default.aspx"&gt;SQL Server Express&lt;/a&gt; which is free for both development and deployment. You get:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;x32/86 or x64 support, &lt;/li&gt;    &lt;li&gt;migration tools to easily import or export your data which comes in very handy when moving to a production database, &lt;/li&gt;    &lt;li&gt;all the programmability support you need like full text search, CLR integration and XML support (this is very cool btw.), &lt;/li&gt;    &lt;li&gt;intellisense, &lt;/li&gt;    &lt;li&gt;and even reporting services allowing you to export to Excel, Word, or PDF &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;u&gt;The Server&lt;/u&gt;     &lt;br&gt;What else but &lt;a href="http://www.iis.net/getstarted" target="_blank" mce_href="http://www.iis.net/getstarted"&gt;IIS&lt;/a&gt; which is again free to use! A modular and extensible platform for hosting your website. It’s has too many features to name but the most important takeaway is that it does all the work for you. It lets you host both .NET and PHP sites which was perfect for me since I wanted &lt;a title="free Indian matrimony and Indian dating" href="http://www.desispark.com/" target="_blank" mce_href="http://www.desispark.com/"&gt;Desi Spark&lt;/a&gt; on ASP .NET but the Desi Spark &lt;a title="free Indian matrimony and Indian dating" href="http://www.desispark.com/blog" target="_blank" mce_href="http://www.desispark.com/blog"&gt;blog&lt;/a&gt; on PHP.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Let’s Take A Breather        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;WOW – is it just me or is that a lot of powerful tech for zero dollars and zero cents ($0.00)! I hope you’re starting to see why I’m so excited and so proud of what Microsoft offers. The crazy thing though, is that I haven’t even mentioned the tools yet…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Tools&lt;/u&gt;&lt;/strong&gt;     &lt;br&gt;I only needed four tools to create Desi Spark and 2 of them were from Microsoft, but they were all free.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;Visual Web Developer Express      &lt;br&gt;&lt;/u&gt;&lt;a href="http://www.asp.net/vwd" target="_blank" mce_href="http://www.asp.net/vwd"&gt;Visual Web Developer Express&lt;/a&gt; is a free development environment that you can use to create and test web applications. It has a design surface, powerful debugging, support for AJAX and jQuery, intellisense and integration with IIS. &lt;/p&gt;  &lt;p&gt;&lt;u&gt;SQL Server Management Studio Express      &lt;br&gt;&lt;/u&gt;The &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b" target="_blank" mce_href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b"&gt;Management Studio&lt;/a&gt; is a free integrated environment for developing and configuring your SQL server. It had everything I needed to build an enterprise ready website. &lt;/p&gt;  &lt;p&gt;&lt;u&gt;AnjLab.SqlProfiler      &lt;br&gt;&lt;/u&gt;During my debugging and testing an SQL profiler was the only tool I cried out for that wasn’t included. Thankfully someone has created a great tool that more than met my needs. Check it out &lt;a href="http://anjlab.com/en/projects/opensource/sqlprofiler" target="_blank" mce_href="http://anjlab.com/en/projects/opensource/sqlprofiler"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;Vault Source Control&lt;/u&gt;     &lt;br&gt;Source control isn’t a must have but it sure makes life easier. I was unable to find a free 1 user license offered by Microsoft so I used &lt;a href="http://www.sourcegear.com/vault/" target="_blank" mce_href="http://www.sourcegear.com/vault/"&gt;Vault&lt;/a&gt; which is straight forward to set up.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Conclusion        &lt;br&gt;&lt;/u&gt;&lt;/strong&gt;So there you have it. Everything I used to create Desi Spark – the first 100% &lt;a title="free Indian matrimony and Indian dating" href="http://www.desispark.com/" target="_blank" mce_href="http://www.desispark.com/"&gt;free Indian matrimony and dating website&lt;/a&gt; – all for free thanks to Microsoft. The framework made it possible, and the tools made it simple. &lt;/p&gt;  &lt;p&gt;What has the &lt;a href="http://www.microsoft.com/web/downloads/platform.aspx" target="_blank" mce_href="http://www.microsoft.com/web/downloads/platform.aspx"&gt;Microsoft Web Platform&lt;/a&gt; empowered you to create?&lt;/p&gt;  &lt;p&gt;AI&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7816821" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET+AJAX/default.aspx">ASP .NET AJAX</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Web+Platform/default.aspx">Web Platform</category></item><item><title>A Distributable (.exe) Silverlight OOB Application</title><link>http://weblogs.asp.net/alnurismail/archive/2010/05/24/a-distributable-exe-silverlight-oob-application.aspx</link><pubDate>Tue, 25 May 2010 01:14:32 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7503449</guid><dc:creator>alnurismail</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7503449</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2010/05/24/a-distributable-exe-silverlight-oob-application.aspx#comments</comments><description>&lt;p&gt;I’ve seen a few questions regarding how to deploy a Silverlight Out of Browser application in an .exe over the past couple days. This post will show you one way of doing that.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create your Silverlight OOB app &lt;/li&gt;    &lt;li&gt;Open up a new .txt file and add:      &lt;br /&gt;&lt;font face="Courier"&gt;&amp;quot;%ProgramFiles(x86)%\Microsoft Silverlight\sllauncher.exe&amp;quot;        &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier"&gt;/overwrite        &lt;br /&gt;/emulate:&amp;quot;MyOOB.xap&amp;quot;         &lt;br /&gt;/origin:http://www.mydomain.com         &lt;br /&gt;&lt;/font&gt;&lt;strong&gt;(remove the line breaks &amp;amp; watch the spaces!)&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Save the file and change the file extension to .bat (i.e. run.bat) &lt;/li&gt;    &lt;li&gt;Run c:\Windows\System32\iexpress.exe &lt;strong&gt;as admin&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Follow the wizard until you’re prompted for the “Packaged Files” &lt;/li&gt;    &lt;li&gt;Add your .xap and .bat &lt;/li&gt;    &lt;li&gt;Continue until you’re promoted for the “Install Program to Launch” &lt;/li&gt;    &lt;li&gt;&lt;font face="Courier"&gt;&lt;font face="Tahoma"&gt;Type&amp;#160; &lt;/font&gt;cmd.exe /C run.bat &lt;/font&gt;&lt;font face="Arial"&gt;for the “Install Program”&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Complete the wizard. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You application should now be packaged in a distributable .exe. &lt;/p&gt;  &lt;p&gt;P.S - If you’ve never heard of sllauncher.exe check out Tim’s blog post &lt;a href="http://timheuer.com/blog/archive/2010/03/25/using-sllauncher-for-silent-install-silverlight-application.aspx" target="_blank"&gt;here&lt;/a&gt;.     &lt;br /&gt;P.S.S – Step 8 is only required if you’re deploying to an x64 machine. Otherwise just specify the .bat file.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7503449" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight 4 Automation from A to Z</title><link>http://weblogs.asp.net/alnurismail/archive/2010/03/15/silverlight-4-automation-from-a-to-z.aspx</link><pubDate>Tue, 16 Mar 2010 00:03:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7384530</guid><dc:creator>alnurismail</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7384530</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2010/03/15/silverlight-4-automation-from-a-to-z.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://www.silverlight.net/getstarted/silverlight-4/" target=_blank mce_href="http://www.silverlight.net/getstarted/silverlight-4/"&gt;Silverlight 4 RC&lt;/A&gt; was released today. This post covers all you need to know about Silverlight 4 Automation. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Background&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Automation (formerly called OLE Automation) is a COM-based technology that enables applications to exposes their unique and/or proprietary features to scripting tools and other applications. Consequently, by using Automation, developers can create custom applications that employ these features to automate frequent tasks.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Silverlight 4 RC&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In Silverlight 4, a number of new classes have been added to the System.Runtime.InteropServices.Automation namespace to enable Automation. This allows Silverlight-based applications to play the role of an Automation client with the ability to directly access the programming model and services exposed by the Automation server. &lt;/P&gt;
&lt;P&gt;This post will run through a simple example of how to 1) access the file system, 2) enumerate over a collection of files, and 3) handle an automation event.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Fundamentals&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Before we get to the example, there are a few basic fundamentals that need to be called out:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Automation is for Windows only &lt;/LI&gt;
&lt;LI&gt;Support for Automation revolves around late-bound COM -- there is no intellisense&lt;/LI&gt;
&lt;LI&gt;Automation can only be run in an &lt;A href="http://msdn.microsoft.com/en-us/library/dd550721(VS.96).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/dd550721(VS.96).aspx"&gt;Out of Browser&lt;/A&gt; application &lt;/LI&gt;
&lt;LI&gt;Automation requires &lt;A href="http://msdn.microsoft.com/en-us/library/ee721083(VS.96).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ee721083(VS.96).aspx"&gt;Elevated Trust&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Production&lt;/STRONG&gt; trusted applications run with current user privileges and &lt;STRONG&gt;cannot&lt;/STRONG&gt; elevate to admin even if the user has admin privileges &lt;BR&gt;(&lt;EM&gt;Note: this does not apply when debugging&lt;/EM&gt;) &lt;/LI&gt;
&lt;LI&gt;COM events that return values are not supported &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;U&gt;Example&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;The first step for the Automation client is to access the Automation server. This is done by ensuring the server is available and then calling CreateObject with a programmatic identifier to get a reference to the server. Since we are accessing the file system we’ll use &lt;EM&gt;Scripting.FileSystemObject &lt;/EM&gt;as the prog id.&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:41f1d8e8-2b77-4991-8a0f-e38d8b4ff5d3 class=wlWriterEditableSmartContent&gt;
&lt;DIV style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;DIV style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;OL style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
&lt;LI&gt;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Application&lt;/SPAN&gt;.Current.IsRunningOutOfBrowser)&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;{&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (!&lt;SPAN style="COLOR: #2b91af"&gt;AutomationFactory&lt;/SPAN&gt;.IsAvailable)&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #2b91af"&gt;MessageBox&lt;/SPAN&gt;.Show(&lt;SPAN style="COLOR: #a31515"&gt;"Automation not available."&lt;/SPAN&gt;);&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;;&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #0000ff"&gt;dynamic&lt;/SPAN&gt; fileSystem = &lt;SPAN style="COLOR: #2b91af"&gt;AutomationFactory&lt;/SPAN&gt;.CreateObject(&lt;SPAN style="COLOR: #a31515"&gt;"Scripting.FileSystemObject"&lt;/SPAN&gt;);&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;(&lt;EM&gt;Note: If you don’t check if the server is available a NotSupportedException will be thrown on platforms where COM is not supported&lt;/EM&gt;)&lt;/P&gt;
&lt;P&gt;(&lt;EM&gt;Note:&lt;/EM&gt; &lt;EM&gt;If there was a failure to load, locate or return a reference to the specific prog id an Exception will be thrown)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Now that we have a reference to our server we can directly access it and get a reference to a directory:&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8198759a-5a3d-4ba9-9a6d-534c0d945f29 class=wlWriterEditableSmartContent&gt;
&lt;DIV style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;DIV style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;OL style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
&lt;LI&gt;&lt;SPAN style="COLOR: #0000ff"&gt;dynamic&lt;/SPAN&gt; folder = fileSystem.GetFolder(&lt;SPAN style="COLOR: #a31515"&gt;"c:\\program files"&lt;/SPAN&gt;);&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;One of the Automation features that wasn’t available in the beta was the ability to enumerate over an IEnumVARIANT collection returned from the server as a result, in this case, of a method call. With this support we can easily foreach to find all subfolders:&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:672eb316-1e84-4844-a29c-ea94eff815f2 class=wlWriterEditableSmartContent&gt;
&lt;DIV style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;DIV style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;OL style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
&lt;LI&gt;&lt;SPAN style="COLOR: #0000ff"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;dynamic&lt;/SPAN&gt; subFolder &lt;SPAN style="COLOR: #0000ff"&gt;in&lt;/SPAN&gt; folder.SubFolders)&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;{&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;To show an example of handling COM events, let’s pump this collection into an excel spreadsheet and notify the user before they close the workbook. In C# there are three ways to attach event handlers to Automation events. You can use the +=/-= syntax that requires the specified delegate to have the same signature as the Automation event signature. Secondly, you can handle the EventRaised event if you don’t know the Automation event signature. Finally, you can use the AddEventHandler/RemoveEventHandler methods that require knowledge of the event signature. I’ve chosen to use the EventRaised event:&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fcf82cbb-343d-472b-a076-2439945a9c8b class=wlWriterEditableSmartContent&gt;
&lt;DIV style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;DIV style="BACKGROUND: #fff; OVERFLOW: auto"&gt;
&lt;OL style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
&lt;LI&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AutomationEvent&lt;/SPAN&gt; beforeCloseEvent = &lt;SPAN style="COLOR: #2b91af"&gt;AutomationFactory&lt;/SPAN&gt;.GetEvent(workbook, &lt;SPAN style="COLOR: #a31515"&gt;"BeforeClose"&lt;/SPAN&gt;);&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;beforeCloseEvent.EventRaised += (sender, e) =&amp;gt;&lt;/LI&gt;
&lt;LI&gt;{&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #2b91af"&gt;MessageBox&lt;/SPAN&gt;.Show(&lt;SPAN style="COLOR: #a31515"&gt;"Closing workbook!"&lt;/SPAN&gt;);&lt;/LI&gt;
&lt;LI&gt;};&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;You can download a sample project &lt;A href="http://cid-e882c47b39adbc49.skydrive.live.com/self.aspx/SilverlightAutomation/SilverlightAutomation.zip" target=_blank mce_href="http://cid-e882c47b39adbc49.skydrive.live.com/self.aspx/SilverlightAutomation/SilverlightAutomation.zip"&gt;here&lt;/A&gt; (VS2010 sln), and that’s the A to Z of Silverlight 4 Automation.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7384530" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Silverlight Shortest Path Simulation</title><link>http://weblogs.asp.net/alnurismail/archive/2009/12/16/silverlight-shortest-path-simulation.aspx</link><pubDate>Wed, 16 Dec 2009 22:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7280754</guid><dc:creator>alnurismail</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7280754</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/12/16/silverlight-shortest-path-simulation.aspx#comments</comments><description>&lt;p&gt;I recently accepted a PM position on the Silverlight team that I’m very excited about. I’ve always kept a close eye on Silverlight but never had the time to invest into the 1s and 0s of Silverlight development . As I slowly transition over I’ve made it a priority to get my hands dirty by building a few apps that use the core Silverlight features.&lt;/p&gt;  &lt;p&gt;The first app I built was a simulation of Dijkstra’s shortest path algorithm. The app allows the user to create their own weighted graph (nodes connected by edges each with an associated cost) to run the simulation on. While running the simulation you’ll see the active nodes and edges changing colors as they get discovered, and chosen or rejected. You can play with the app below (source at the bottom) but one warning – this is a POC so error handling, testing, and UX are minimal.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;The UI&amp;#160; is lacking and doesn’t have clear affordances for its use so here are the steps:      &lt;br /&gt;&lt;/em&gt;&lt;em&gt;1) Make sure ‘Add Nodes’ at the top is selected then click anywhere to create some nodes      &lt;br /&gt;2) Make sure ‘Add Edges’ at the top is selected then click on two nodes to connect them with an edge       &lt;br /&gt;3) Set the weight of the edge by typing in a number in the textbox associated with the edge       &lt;br /&gt;4) Repeat to create a simple/complex graph&lt;/em&gt;&lt;em&gt;      &lt;br /&gt;5) S&lt;/em&gt;&lt;em&gt;et the source and target (the value of the node) and run the simulation.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="400" height="400" autoupdate="true"&gt; &lt;param name="source" value="http://weblogs.asp.net/blogs/alnurismail/121609/ShortestPath.zip" /&gt; &lt;param name="minRuntimeVersion" value="3.0.40624.0" /&gt; &lt;param name="background" value="White" /&gt; &lt;param name="autoUpgrade" value="true" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=3.0.40624.0" style="text-decoration:none"&gt;          			  &lt;img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none" /&gt; &lt;/a&gt; &lt;/object&gt;&lt;/p&gt;  &lt;p&gt;The goal of this POC was to create an app that showed the algorithm at work without tightly coupling the model (graph), algorithm (Dijkstra), and view (UI updates).&lt;/p&gt;  &lt;p&gt;Here’s a high level overview:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;1) Design&lt;/u&gt;&lt;/strong&gt;     &lt;br /&gt;    &lt;br /&gt;To avoid tightly coupling the model, algorithm, and view I used a design pattern similar to MVC. I opted for a similar pattern because with MVC it’s hard to have a controller that’s suited for an interactive UI. Instead I used the MVVM (Model-View-ViewModel) pattern which works well with Silverlight because it overcomes the interactive UI problem, and still lets you loosely couple the app.&amp;#160; &lt;br /&gt;    &lt;br /&gt;The ViewModel sits between the View and the Model and knows nothing about the View. The View on the other hand is tightly coupled to the ViewModel because it consumes the ViewModel via data-binding.     &lt;br /&gt;    &lt;br /&gt;For my app having a data-bound ViewModel didn’t make sense so instead I let the ViewModel throw events that the View would catch.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;2) Graph&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The graph breaks down into two logical objects: Nodes and Edges. I created a node user control, to abstract the Node logic for reusability, which gets created and added to the Canvas in response to the MouseLeftButtonUp event. I set the node-control’s position based on the mouse position using the Canvas.Left and Canvas.Top dependency properties.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:59f962d0-239e-4da3-8e5a-87271202ee08" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;node.SetValue(&lt;span style="color:#2b91af"&gt;Canvas&lt;/span&gt;.LeftProperty, ...);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;node.SetValue(&lt;span style="color:#2b91af"&gt;Canvas&lt;/span&gt;.TopProperty, ...);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;To connect the nodes with an edge I exposed an event that is called in response to the node-control’s MouseLeftButtonUp. This allows me to track which nodes the user is selecting. Once the user selects two distinct nodes I create a Line with it’s {X1,Y1} and {X2,Y2} properties set to the first and second nodes’ position respectively. To make it look “nicer” I use the Canvas.ZIndexProperty to push the edge behind the nodes. &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:478cff36-77f7-42b2-9a5d-f74a3ff5002a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;edge.X1 = edgeStart.X;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;edge.Y1 = edgeStart.Y;&lt;/li&gt; &lt;li&gt;edge.X2 = edgeEnd.X;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;edge.Y2 = edgeEnd.Y;&lt;/li&gt; &lt;li&gt;edge.SetValue(&lt;span style="color:#2b91af"&gt;Canvas&lt;/span&gt;.ZIndexProperty, (&lt;span style="color:#0000ff"&gt;int&lt;/span&gt;)edge.GetValue(&lt;span style="color:#2b91af"&gt;Canvas&lt;/span&gt;.ZIndexProperty) - &lt;span style="color:#a52a2a"&gt;1&lt;/span&gt;);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The final step is to add a Textbox so the user can assign a weight to the edge. This done in similar fashion to adding edges.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;3) Simulation (Updating UI)&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In Silverlight you can explicitly execute a method on the UI thread by calling Dispatcher.BeginInvoke(…) that accepts a delegate.&amp;#160; However, you must ensure that you don’t block the UI thread with any lengthy computations like computing the shortest path. &lt;/p&gt;  &lt;p&gt;Consequently, I created a new thread to run Dijkstra’s algorithm on.   &lt;br /&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5336255a-b772-44e4-8b1e-2081b934c9cb" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;tAlg = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Thread&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ParameterizedThreadStart&lt;/span&gt;(FindShortestPath));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;tAlg.Start(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ShortestPathAlgParams&lt;/span&gt;() { Source = txtSource.Text.Trim(), Target = txtTarget.Text.Trim() });&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The algorithm updates the state of the nodes and edges in the graph which in turn raise a series of events that bubble up to the View that invokes the UI update. &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3ef36d33-0af5-47ac-a7ce-fc9b695eb1da" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ViewModelChangeEvent(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;ViewModelChangeEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Dispatcher.BeginInvoke(() =&amp;gt; UpdateView(e));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I’m eager to know if this was the best way to design and implement this POC in SL. If you look at the source and see anything that can be improved upon using existing SL features drop me a comment and let me know.&lt;/p&gt;  &lt;p&gt;Source &lt;a href="http://cid-e882c47b39adbc49.skydrive.live.com/self.aspx/SL%5E_ShortestPathSimulation/ShortestPath.zip" target="_blank"&gt;here&lt;/a&gt;. (Built using VS2010)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7280754" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Recreating Google’s NewsShow using Bing</title><link>http://weblogs.asp.net/alnurismail/archive/2009/10/16/recreating-google-s-newsshow-using-bing.aspx</link><pubDate>Fri, 16 Oct 2009 20:09:33 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7231642</guid><dc:creator>alnurismail</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7231642</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/10/16/recreating-google-s-newsshow-using-bing.aspx#comments</comments><description>&lt;p&gt;I’ve been looking at and learning the &lt;a href="http://www.bing.com/developers" target="_blank"&gt;Bing 2.0’s API&lt;/a&gt; recently, and comparing it to Google’s API. While browsing Google’s &lt;a href="http://code.google.com/apis/ajaxsearch/" target="_blank"&gt;AJAX Search API&lt;/a&gt; I noticed that Google is focusing on letting their users embed simple apps/controls that take advantage of their search API which provide a lot of value for minimal time invested. I tried to find a similar offering from Bing but came up empty. That’s a pretty smart tactic because if I were an end user (read: not a power user) deciding to leverage an API for my site I would lean heavily toward Google because the barrier to entry is just a few lines of JavaScript. One of Google’s apps that I really liked was the &lt;a href="http://code.google.com/apis/ajaxsearch/documentation/newsshow/" target="_blank"&gt;NewsShow&lt;/a&gt; which lets&amp;#160; users see rotating headlines and previews of Google News Search based on queries that you select. In an attempt to become familiar with the Bing 2.0 API and drink the MS Kool-Aid I decided to recreate that functionality using Bing as the search provider.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/alnurismail/image_04C2CC78.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Google&amp;#39;s NewsShow" border="0" alt="Google&amp;#39;s NewsShow" src="http://weblogs.asp.net/blogs/alnurismail/image_thumb_636326DB.png" width="732" height="94" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;Google’s NewsShow &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/alnurismail/image_2973E3EF.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/alnurismail/image_thumb_6865648A.png" width="665" height="85" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;Alnur’s Some What Ghetto NewsShow Using Bing &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I’ve copied the code into this blog post since it’s just JavaScript so what you’re, hopefully, seeing below is the actual control running. The code is straight forward: a loop that grabs news head lines for a specific topic, shows the first 4, and then repeats for the next topic.&lt;/p&gt;  &lt;p&gt;&lt;script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;
        // Replace the following string with the AppId you received from the
        // Bing Developer Center.
        var AppId = "AEAD1B8FE5764764B9DC68ADF272342B815E0BB0";
        var _categoryOffset = 0;
        var _articleOffset = 0;
        var _categories = ["", "rt_Business", "rt_Entertainment", "rt_Health", "rt_Political", "rt_Scientific", "rt_Sports", "rt_World", "rt_ScienceAndTechnology"];
        var _categoriesReadable = ["Top Stories", "Business", "Entertainment", "Health", "Political", "Scientific", "Sports", "World", "Technology"];
        var _articles = [];

        $(function() {
            DisplayNews();
        })

        function DisplayNews() {
            if (_articles.length == 0) {
                GetNews();
            }
            else {
                if (_articleOffset &gt;= 4) {
                    _categoryOffset = (_categoryOffset &gt;= _categories.length - 1) ? 0 : _categoryOffset + 1; //circluar
                    _articleOffset = 0;
                    GetNews();
                }
                else {
                    RenderNews();
                }
            }
        }

        //Get the top news stories for each category.
        function GetNews() {
            var requestStr = "http://api.search.live.net/json.aspx?"

            // Common request fields (required)
            + "AppId=" + AppId
            + "&amp;Query="
            + "&amp;Sources=News"
            + "&amp;News.Category=" + _categories[_categoryOffset]
            + "&amp;JsonType=callback"
            + "&amp;JsonCallback=?";

            $.ajax({
                type: "GET",
                url: requestStr,
                dataType: "jsonp",
                success: function(response) {
                    GetNewsComplete(response);
                },
                error: function(response) {
                    alert("Error: " + response.d);
                }
            });
        }

        function GetNewsComplete(response) {
            var errors = response.SearchResponse.Errors;
            if (errors != null) {
                // There are errors in the response. Display error details.
                DisplayErrors(errors);
            }
            else {
                // There were no errors in the response. Redner the
                // News results.
                _articles = response.SearchResponse.News.Results
                RenderNews();
            }
        }

        function RenderNews() {
            if (_articles[_articleOffset] &amp;&amp; _articles[_articleOffset].Snippet) {
                $(".ai-qtitle").html(_categoriesReadable[_categoryOffset]);
                $(".ai-title").html("&lt;a href=\"" + _articles[_articleOffset].Url + " target=\"_parent\" class=\"ai-title-link\"&gt;" + _articles[_articleOffset].Title + "&lt;/a&gt;");
                $(".ai-source").html(_articles[_articleOffset].Source);
                $(".ai-snippet").html(_articles[_articleOffset].Snippet);

                _articleOffset++;
                setTimeout("DisplayNews()", 5000)
            }
            else {
                _articleOffset++;
                DisplayNews();
            }
        }

        function DisplayErrors(errors) {
            //....
        }
    &lt;/script&gt;&lt;/p&gt; &lt;style type="text/css"&gt;


        .ai-root
        {
            font-family: arial, sans-serif;
            font-size: 13px;
            position: relative;
        }
        
        /* Absolute Objects */
        .ai-basecanvas, .ai-poweredby, .ai-poweredbydivider, .ai-result, .ai-query-title
        {
            position: absolute;
        }

        .ai-title a:link, .ai-title a:visited
        {
            color: #000099;
            text-decoration: underline;
        }
        
        /* Common Colors and Sizes */
        .ai-title
        {
            font-weight: bold;
        }

        .ai-snippet
        {
            font-size: 90%;
            color: #000000;
        }
        
        .ai-source
        {
            color: #666666;
        }
        
        .ai-query-title
        {
            color: #000000;
            font-size: 18px;
            font-weight: normal;
        }
        
        .ai-658x80
        {
            width: 658px;
            height: 80px;
            background-color: #ccd9f2;
        }
        
        .ai-658x80 .ai-basecanvas
        {
            top: 1px;
            left: 1px;
            width: 656px;
            height: 78px;
            background-color: #ffffff;
        }
        
        .ai-658x80 .ai-query-title
        {
            width: 163px;
            text-align: center;
            line-height: 1.3em;
            height: 1.3em;
            overflow: hidden;
        }
        
        .ai-generic-658x80 .ai-query-title
        {
            top: 25px;
        }
        
        .ai-658x80 .ai-result
        {
            top: 5px;
            left: 175px;
            width: 455px;
        }
        
        .ai-658x80 .ai-title
        {
            line-height: 1.3em;
            height: 1.3em;
            overflow: hidden;
        }
        
        .ai-658x80 .ai-sourceandtime
        {
            line-height: 1.3em;
            height: 1.3em;
            overflow: hidden;
        }
        
        .ai-658x80 .ai-snippet
        {
            line-height: 1.3em;
            height: 2.6em;
            overflow: hidden;
            margin-bottom: 2px;
        }
    &lt;/style&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div class="ai-root ai-658x80 ai-generic-658x80"&gt;   &lt;div class="ai-basecanvas"&gt;     &lt;div class="ai-result"&gt;       &lt;div class="ai-title"&gt;&lt;a class="ai-title-link" href="http://www.thestar.com/news/world/article/711237--no-indication-balloon-stunt-a-hoax-colorado-sheriff-says%20target=" _parent?="_parent?"&gt;No indication balloon stunt a hoax, Colorado sheriff says&lt;/a&gt;&lt;/div&gt;        &lt;div class="ai-sourceandtime"&gt;&lt;span class="ai-source"&gt;Toronto Star&lt;/span&gt;&lt;/div&gt;        &lt;div class="ai-snippet"&gt;FORT COLLINS, COLO. – The Larimer County sheriff's department in Colorado says they have no indication a family was carrying out a hoax when they reported their 6-year-old son was in a helium balloon that floated away from their home. The boy was found hiding in the home's garage Thursday ... &lt;/div&gt;     &lt;/div&gt;   &lt;/div&gt;    &lt;div class="ai-query-title"&gt;     &lt;div class="ai-qtitle"&gt;Top Stories&lt;/div&gt;   &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;The Ghetto NewsShow in full flight&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Feel free to SAM (steal and modify) but if you end up using/improving it let me know! &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7231642" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Bing/default.aspx">Bing</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>Part 2 – Object Oriented JavaScript (MS AJAX)</title><link>http://weblogs.asp.net/alnurismail/archive/2009/06/22/part-2-object-oriented-javascript-ms-ajax.aspx</link><pubDate>Mon, 22 Jun 2009 16:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7132089</guid><dc:creator>alnurismail</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7132089</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/06/22/part-2-object-oriented-javascript-ms-ajax.aspx#comments</comments><description>
&lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;I recently gave a presentation on Object Oriented JavaScript (OOJ) and received some good feedback so the next few posts will be a more verbose version of that presentation.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;u&gt;AGENDA&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx" target="_blank" mce_href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx"&gt;Part 1 – JavaScript Review&lt;/a&gt; &lt;br&gt;Part 2 – How &lt;br&gt;Part 3 – Why Use OOJ? &lt;br&gt;Part 4 – Example&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;u&gt;Part 2 – How&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Custom Objects&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Using what was covered in &lt;a href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx" target="_blank" mce_href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx"&gt;Part 1&lt;/a&gt; we can start to create our own custom objects. First we need to write a constructor by using a function:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; Team(name, league) {&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._name = name;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._league = league;&lt;br&gt;}&lt;/pre&gt;&amp;nbsp; &lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;To create an instance of a Team we can use the function together with the &lt;i&gt;new&lt;/i&gt; operator to create a new object and invoke the constructor:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; t = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Team(&lt;span style="color: rgb(0, 96, 128);"&gt;'Arsenal'&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;'EPL'&lt;/span&gt;);&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;p&gt;&lt;u&gt;The Prototype Object&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Briefly mentioned in &lt;a href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx" target="_blank" mce_href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx"&gt;Part 1&lt;/a&gt; the prototype object defines the template of an object. It is similar to a class in C# because it holds all the properties that will be inherited by any instance. However, there is one major difference between an instance of an object in C# that inherits from a class, and an object in JS that inherits from the prototype – &lt;b&gt;all objects and arrays added to the prototype are shared between all instances&lt;/b&gt;. Consequently, it is a best practice to store all the members in the constructor and all methods in the prototype. If you are interested in learning more about the prototype object you can &lt;i&gt;&lt;font color="#ff8000"&gt;[Kool-Aid alert]&lt;/font&gt;&lt;/i&gt;&amp;nbsp;&lt;a href="http://www.bing.com/search?q=javascript+prototype+object" target="_blank" mce_href="http://www.bing.com/search?q=javascript+prototype+object"&gt;Bing it&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;The Microsoft AJAX Library&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;If you’re using ASP .NET to build AJAX infused applications you’ve probably heard about and used the &lt;a href="http://www.asp.net/ajax/AjaxControlToolkit/Samples/" target="_blank" mce_href="http://www.asp.net/ajax/AjaxControlToolkit/Samples/"&gt;AJAX Control Toolkit&lt;/a&gt;. Maybe you’ve wondered how these MS guys create such powerful controls? Well, if you take a look at the source you’ll see that they are are using the MS AJAX library to OOJ (&lt;i&gt;it’s a verb and a noun&lt;/i&gt;). So why the hype? Because the MS AJAX library lets you &lt;b&gt;easily&lt;/b&gt; simulate OO constructs such as: classes, properties, interfaces and enumerations that are not currently supported in JavaScript. Let’s take a look at how to use the library…&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Classes&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;To make the above Team object a class all we need to add is &lt;b&gt;one&lt;/b&gt; line of code after the constructor has been declared:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; Team(name, league) {&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._name = name;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._league = league;&lt;br&gt;}&lt;br&gt;Team.prototype = {&lt;br&gt;    getRoster : &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;//..&lt;/span&gt;&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//code responsible for making the constructor behave as a class&lt;/span&gt;&lt;br&gt;Team.registerClass(&lt;span style="color: rgb(0, 96, 128);"&gt;'Team'&lt;/span&gt;);&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;The registerClass in the above example is responsible for making the constructor behave as a class but it can do more that just that. It is responsible for:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Registering the type name (ex. Team) in the constructor so you can access it at runtime (normally you declare a class by assigning it to a namespace variable so the class becomes an anonymous function which I talked about in &lt;a href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx" target="_blank" mce_href="http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx"&gt;Part 1&lt;/a&gt;. &lt;b&gt;You always want to use the fully qualified name of the class otherwise you loose the ability to access it&lt;/b&gt;.) &lt;/li&gt;

&lt;li&gt;Resolving an inheritance relationship if a base class is provided &lt;/li&gt;

&lt;li&gt;Letting you specify one or many interfaces &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of how to use registerClass to do those three things :&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;FIFA.League.EPL.Team.registerClass(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.League.EPL.Team'&lt;/span&gt;&lt;br&gt;                                    , FIFA.League.Team&lt;br&gt;                                    , FIFA.League.ITeam);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;This translate to:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;FullyQualifiedClassName.registerClass('FullyQualifiedClassName'&lt;br&gt;                                        , BaseClass&lt;br&gt;                                        , Interface);&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;div&gt;&lt;u&gt;Properties&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;To expose properties (aka getters and setters in C#) in a JavaScript object add two functions to the Team prototype object like so:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;Team.prototype = {&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;//...&lt;/span&gt;&lt;br&gt;    getName() : &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; () {&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._name;},&lt;br&gt;    setName(): &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; (value) { &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._name = value;}&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;By declaring member variables using this pattern there is no way to set private scope so although you could just directly get/set the variables you would loose the ability to perform any required logic. (&lt;i&gt;Note: there is a way to make a variable private in JS using closures but it won’t work following the MS AJAX best practices. I’ll write another post about that because sometimes I’ve found MS AJAX to be overkill when you need a simple standalone object.&lt;/i&gt;)&lt;/div&gt;
&lt;p&gt;&lt;u&gt;Namespaces&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;From the registerClass example above the Team class is being accessed through a series of namespaces. To create a namespace use:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;Type.registerNamespace(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA'&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;For a nested namespace use:&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;Type.registerNamespace(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.League'&lt;/span&gt;);&lt;/pre&gt;&lt;br&gt;&lt;u&gt;Inheritance&lt;/u&gt;&lt;/div&gt;
&lt;p&gt;Remember that to accomplish inheritance in JS we need to inherit from the prototype object. We do this by using the registerClass method that was shown above. But, we also need a way to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Call the base constructor &lt;/li&gt;

&lt;li&gt;Pass parameters to the base constructor &lt;/li&gt;

&lt;li&gt;Override methods inherited from the base &lt;/li&gt;

&lt;li&gt;Call base methods &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MS AJAX makes these four tasks fairly simple. To call the base class constructor and to pass it some parameters use the initializeBase(…) method that takes two parameters. The first parameter is the child class that is inheriting and the second is an array of parameters we need to pass. To override a method replace the function with your own just like in C#, and calling a base method is as easy as calling the callBaseMethod(…) method which takes three parameters: the current instance, the method name to call, and an array of method parameters.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;&lt;p&gt;Type.registerNamespace(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA'&lt;/span&gt;);&lt;/p&gt;&lt;br&gt;&lt;p&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//Player Base Class&lt;/span&gt;&lt;br&gt;FIFA.Player = &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; (name, age) {&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._name = name;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._age = age;&lt;br&gt;}&lt;br&gt;FIFA.Player.prototype = {&lt;br&gt;    strategy : &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;//Perform player logic&lt;/span&gt;&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;FIFA.Player.registerClass(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.Player'&lt;/span&gt;);&lt;/p&gt;&lt;br&gt;&lt;p&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//Defender Derived Class&lt;/span&gt;&lt;br&gt;FIFA.Defender = &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;(name, age) {&lt;br&gt;    FIFA.Defender.initializeBase(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, [name, age]);&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;//Perform additional logic &lt;/span&gt;&lt;br&gt;}&lt;br&gt;FIFA.Defender.prototype = {&lt;br&gt;    strategy : &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;br&gt;        FIFA.Defender.callBaseMethod(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;'strategy'&lt;/span&gt;);&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;//Perform additional logic&lt;/span&gt;&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;FIFA.Defender.registerClass(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.Defender'&lt;/span&gt;, FIFA.Player);&lt;/p&gt;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;
&lt;p&gt;&lt;u&gt;Interfaces &amp;amp; Enumerations&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Interfaces and enumerations follow a similar pattern. MS AJAX uses functions to implement both but we need to stop a user from calling the constructor to create instances of them, and also stop a user from calling the methods of the interface. This can be achieved by using Error.notImplemented() in the function body so the actions error out “by design”. We define the functions of the interface or the names of the enumeration in the prototype, and after the declaration call either registerInterface or registerEnum. &lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;FIFA.Leagues.Teams.ITeam.registerInterface(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.Leagues.Teams.ITeam'&lt;/span&gt;);&lt;br&gt;FIFA.Results.registerEnum(&lt;span style="color: rgb(0, 96, 128);"&gt;'FIFA.Results'&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the next and final part of this series I’ll talk about why you should use OOJ and also provide a comprehensive example that ties everything together.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7132089" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET+AJAX/default.aspx">ASP .NET AJAX</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Javascript/default.aspx">Javascript</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/MS+AJAX/default.aspx">MS AJAX</category></item><item><title>Part 1 - Object Oriented JavaScript (Using MS AJAX)</title><link>http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx</link><pubDate>Sun, 14 Jun 2009 02:48:16 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7121339</guid><dc:creator>alnurismail</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7121339</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/06/13/part-1-object-oriented-javascript-using-ms-ajax.aspx#comments</comments><description>&lt;p&gt;I recently gave a presentation on Object Oriented JavaScript (OOJ) and received some good feedback so the next few posts will be a more verbose version of that presentation.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;AGENDA&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Part 1 – JavaScript Review    &lt;br /&gt;Part 2 – How     &lt;br /&gt;Part 3 – Why Use OOJ?     &lt;br /&gt;Part 4 – Example&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;&lt;u&gt;Part 1 – JavaScript Review&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Before we get to the good stuff I want to review the basic fundamentals of JavaScript which we will build on in Part 2.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;JavaScript Objects&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;Believe it or not, JavaScript is a &lt;strong&gt;true&lt;/strong&gt; object oriented language. However, objects in JavaScript are different than objects in C# because JavaScript doesn’t have classes which means you can’t create an instance of a class like you would in C#. Instead you need to manipulate the native Prototype object which can be though of as a template. The Prototype object will be discussed in detail a little later. So what is a JavaScript object? Put simply, a JavaScript object is no more than a collection of name/value pairs. &lt;/p&gt;  &lt;p&gt;You can create a JavaScript object by using:&amp;#160;&amp;#160; &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; person = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Object();&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;JavaScript Properties&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;JavaScript properties can be added at any time unlike C# where all properties are defined in the class. Properties can be added by using:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;person.name = &lt;span style="color: #006080"&gt;'Alnur Ismail'&lt;/span&gt;;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;Or, to show that JS objects are really no more than a collection of name/value pairs we can use the indexed notation.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;person[&lt;span style="color: #006080"&gt;'gender'&lt;/span&gt;] = male;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;u&gt;JavaScript Functions&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;In JS functions are first class objects. This is a fancy way of saying they can do everything regular objects can do such as being: instantiated, returned by other functions, stored as elements of arrays and assigned to variables. The latter, also referred to as an anonymous function, is important to understand when it comes to OOJ because when a function is assigned to a variable there is no way of getting to that function without knowing the property name. More on this later.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;That’s all you really need to know about JavaScript to take advantage of OOJ. I’ll discuss the “how” of OOJ in Part 2.
  &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7121339" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET+AJAX/default.aspx">ASP .NET AJAX</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Javascript/default.aspx">Javascript</category></item><item><title>Use ExpressionBuilder To Avoid “Server tags cannot contain &lt;% … %&gt; constructs”</title><link>http://weblogs.asp.net/alnurismail/archive/2009/04/18/use-expressionbuilder-to-avoid-server-tags-cannot-contain-lt-gt-constructs.aspx</link><pubDate>Sat, 18 Apr 2009 19:48:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7049844</guid><dc:creator>alnurismail</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7049844</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/04/18/use-expressionbuilder-to-avoid-server-tags-cannot-contain-lt-gt-constructs.aspx#comments</comments><description>&lt;P&gt;The ExpressionBuilder is still unknown to a lot of developers that haven’t experienced the sadistic pleasure of localizing a web application. It was introduce in ASP .NET 2.0 and allows you to bind values to control properties using declarative expressions. &lt;/P&gt;
&lt;P&gt;I learnt about the ExpressionBuilder when I was doing some research on localization best practices in .NET. The recommendation is to use the specialized ResourceExpressionBuilder that creates code to retrieve resource values when the page is executed.&lt;/P&gt;
&lt;P&gt;The ResourceExpressionBuilder is great for localization but what if we want to bind a control’s property to something else? Maybe a value in the Web.config’s AppSetting section. You may have tried something like this:&amp;nbsp; &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:TextBox&lt;/SPAN&gt; &lt;BR&gt;&lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="foo"&lt;/SPAN&gt; &lt;BR&gt;&lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN class=attr&gt;text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="&amp;lt;%=ConfigurationManager.AppSettings["&lt;/SPAN&gt;&lt;SPAN class=attr&gt;FooText&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;"] %&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Don’t be embarrassed. We’ve all done it at least once, and we’ve all been greeted with: &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Parser Error Message: &lt;/B&gt;Server tags cannot contain &amp;lt;% ... %&amp;gt; constructs.&lt;/P&gt;
&lt;P&gt;Thankfully there is an ExpressionBuilder that can help. the AppSettingsExpressionBuilder provides access to values in the AppSettings section of the Web.config and we use it as follows:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:TextBox&lt;/SPAN&gt; &lt;BR&gt;&lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="foo"&lt;/SPAN&gt; &lt;BR&gt;&lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN class=attr&gt;text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="&amp;lt;%$ AppSettings: FooText %&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;

.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; }&lt;/STYLE&gt;

&lt;P&gt;The ResourceExpressionBuilder and the AppSettingsExpressionBuilder are both derived from the ExpressionBuilder base class. That means we can create our own but I'll leave that topic for another day.&lt;/P&gt;
&lt;P&gt;Keep in mind that the ExpressionBuilder only works when it is assigned to the property of a control. So you won’t be able to use it, for example, to pass values to a JavaScript constructor. 
&lt;STYLE type=text/css&gt;



.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; }&lt;/STYLE&gt;
&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7049844" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>Maintaining Context in a JavaScript Callback</title><link>http://weblogs.asp.net/alnurismail/archive/2009/04/07/maintaining-context-in-a-javascript-callback.aspx</link><pubDate>Wed, 08 Apr 2009 06:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7034912</guid><dc:creator>alnurismail</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=7034912</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/04/07/maintaining-context-in-a-javascript-callback.aspx#comments</comments><description>&lt;P&gt;For reference. To maintain context in a JavaScript callback use a closure and an anonymous function. For example:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; curObj = &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;; &lt;SPAN class=rem&gt;//closure to get context in callback&lt;/SPAN&gt;
$(&lt;SPAN class=str&gt;'#foobar'&lt;/SPAN&gt;).animate({ height: 100 }, 1000, &lt;SPAN class=str&gt;"jswing"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;() { 
   alert(curObj.someProperty); 
});&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.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; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;


.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; }&lt;/STYLE&gt;

&lt;P&gt;To avoid the anonymous function use the Microsoft Ajax helper &lt;EM&gt;Function.createDelegate&lt;/EM&gt; as follows:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.animate = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;() {
   $(&lt;SPAN class=str&gt;'#foobar'&lt;/SPAN&gt;).animate({ height: 100 }, 1000, &lt;SPAN class=str&gt;"jswing"&lt;/SPAN&gt;, 
      Function.createDelegate(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.AnimateCallback)
);};

&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.AnimateCallback = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;() {
   alert(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.someProperty);
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.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; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;


.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; }&lt;/STYLE&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7034912" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET+AJAX/default.aspx">ASP .NET AJAX</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Javascript/default.aspx">Javascript</category></item><item><title>UI Unit Testing with WatiN - Part #2 – Tips &amp; Tricks</title><link>http://weblogs.asp.net/alnurismail/archive/2009/03/07/ui-unit-testing-with-watin-part-2-tips-amp-tricks.aspx</link><pubDate>Sun, 08 Mar 2009 05:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6946199</guid><dc:creator>alnurismail</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=6946199</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/03/07/ui-unit-testing-with-watin-part-2-tips-amp-tricks.aspx#comments</comments><description>&lt;P&gt;In my &lt;A href="http://weblogs.asp.net/alnurismail/archive/2008/12/12/ui-unit-testing-with-watin-part-1-introduction.aspx" target=_blank mce_href="http://weblogs.asp.net/alnurismail/archive/2008/12/12/ui-unit-testing-with-watin-part-1-introduction.aspx"&gt;first post&lt;/A&gt; about &lt;A href="http://watin.sourceforge.net/" target=_blank mce_href="http://watin.sourceforge.net/"&gt;WatiN&lt;/A&gt; I introduced the open source API, and provided a simple demo to give a taste of what WatiN is capable off. I ended that post with a promise to write a follow up on some of the lessons I’ve learnt. Here they are:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;.NET control ids are not friendly &lt;BR&gt;&lt;/STRONG&gt;WatiN allows you to select any DOM element based on a specified id (or a myriad of other attributes) as follows: &lt;PRE class=csharpcode&gt;_ie.TextField(&lt;SPAN class=str&gt;"controlId"&lt;/SPAN&gt;)&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;








.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; }&lt;/STYLE&gt;

&lt;P&gt;Unfortunately, .NET control ids are rarely as friendly.You’ll quickly find your tests littered with control ids like ‘ctl00_ContentPlaceHolder_ControlId’ making the tests hard to read and overly verbose. The solution is to supply your own regular expression when selecting an element to match only the end of the control id as shown below.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; Regex PartialClientId(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; partialClientId)
{
   &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Regex(&lt;SPAN class=str&gt;".*_"&lt;/SPAN&gt; + partialClientId + &lt;SPAN class=str&gt;"$"&lt;/SPAN&gt;);
} &lt;STYLE type=text/css&gt;



.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; }&lt;/STYLE&gt;&lt;/PRE&gt;
&lt;P&gt;To use the regular expression you need to provide it as a parameter to the selector:&lt;/P&gt;&lt;PRE class=csharpcode&gt;_ie.TextField(PartialClientId(&lt;SPAN class=str&gt;"controlId"&lt;/SPAN&gt;))&lt;BR&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Tests are linked to ids &lt;BR&gt;&lt;/STRONG&gt;Finding a control by id (or name, class, etc.) creates a dependency on that id not changing. Refactoring a control’s id will break all tests relying on it causing you to make sweeping changes which takes time. The solution I use is to create a static class for each web form in my website, under my test project. The class defines constants for all control ids (or names, classes, etc.) that could be referenced in the unit tests. The unit tests use the constants instead of the actual control ids meaning that any change in the web form only needs to be made in one place. &lt;BR&gt;&lt;BR&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Tests repeat &lt;BR&gt;&lt;/STRONG&gt;If you’re building a suite of tests for your website you’ll quickly see that you have to perform the same actions again and again. For example, if you’re testing your e-store you’ll have unit tests for searching for a product and adding products to the shopping cart. If you code these two tests from scratch, the second test would include searching for products. Again, this means if you make any changes to your search unit test you’ll need to make the same change somewhere else. A simple solution is to think of code re-use. Create helper methods for each action like searching, and then call it where appropriate. For example, my helper method would accept a search string and return the results grid. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;That’s all I’ve got so far. Hope it helps.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6946199" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/WatiN/default.aspx">WatiN</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Web+Test/default.aspx">Web Test</category></item><item><title>Running WCF Ajax-enabled services on Windows Server 2008</title><link>http://weblogs.asp.net/alnurismail/archive/2009/02/04/running-wcf-ajax-enabled-services-on-windows-server-2008.aspx</link><pubDate>Wed, 04 Feb 2009 21:37:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6882928</guid><dc:creator>alnurismail</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=6882928</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/02/04/running-wcf-ajax-enabled-services-on-windows-server-2008.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Yesterday I was trying to run an ASP .NET website that leveraged multiple WCF Ajax-enabled services on a Windows Server 2008 box under an IIS7 application but&amp;nbsp;kept running into the following JavaScript error:&amp;nbsp; &lt;EM&gt;"Namespace.Service is undefined". &lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;One of my co-workers had run into this recently and told me the problem was WCF Activation is turned off by default in Windows Server 2008. To turn it on:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Go to Server Manager&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Find the Features Summary&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Click "Add Features"&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Expand the ".NET Framework 3.0 Features" node&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Select "WCF Activation"&amp;nbsp;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Hit "Install"&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;Problem solved.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6882928" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET+AJAX/default.aspx">ASP .NET AJAX</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/WCF/default.aspx">WCF</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Windows+Server+2008/default.aspx">Windows Server 2008</category></item><item><title>A better alternative to using alert() for debugging.</title><link>http://weblogs.asp.net/alnurismail/archive/2009/01/12/a-better-alternative-to-using-alert-for-debugging.aspx</link><pubDate>Mon, 12 Jan 2009 23:02:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6832119</guid><dc:creator>alnurismail</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=6832119</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2009/01/12/a-better-alternative-to-using-alert-for-debugging.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;We've all used, and unfortunately some people continue to use, alert() to help debug JavaScript. Thankfully the Microsoft Ajax Library has a Sys.Debug class that exposes methods for logging messages to the browser’s JavaScript console. For reference:&lt;/P&gt;
&lt;P mce_keep="true"&gt;To log a message to the console use: Sys.Debug.trace(“Log this message to the console”);&lt;/P&gt;
&lt;P mce_keep="true"&gt;To dump an object use: Sys.Debug.traceDump(someObject);&lt;/P&gt;
&lt;P mce_keep="true"&gt;If you don’t have a JavaScript console download the Web Development Helper for IE, and Firebug for Firefox, or add the following textarea element to your page:&lt;BR&gt;&amp;lt;textarea id=”TraceConsole” rows=”50” cols=”50”&amp;gt;&amp;lt;/textarea&amp;gt;&lt;BR&gt;This will display all&amp;nbsp;your trace messages&amp;nbsp;in the textarea.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6832119" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/Javascript/default.aspx">Javascript</category></item><item><title>UI Unit Testing with WatiN - Part #1 - Introduction</title><link>http://weblogs.asp.net/alnurismail/archive/2008/12/12/ui-unit-testing-with-watin-part-1-introduction.aspx</link><pubDate>Sat, 13 Dec 2008 00:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6780114</guid><dc:creator>alnurismail</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alnurismail/rsscomments.aspx?PostID=6780114</wfw:commentRss><comments>http://weblogs.asp.net/alnurismail/archive/2008/12/12/ui-unit-testing-with-watin-part-1-introduction.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;There is an arsenal of tools readily available for unit testing web applications. Unit testing both the data access and business logic tiers is a common best practice and a requirement for developing complex web applications. Solutions typically contain hundreds of unit tests exercising every possible use case and edge case covering the data access and business logic tiers but the UI tier is consistently ignored because the tools to create UI unit tests are not robust enough and hard to use.&lt;/P&gt;
&lt;P mce_keep="true"&gt;If you are familiar with VSTS you may be wondering if Web Tests can fit the bill. Although it is possible to exercise the UI using Web Tests they don’t really help you get down to the granularity of being able to assert that clicking a button causes a textbox to reset, and in this crazy world of AJAX and Web 2.0 we need a tool that handles dynamic changes to the DOM without breaking a sweat.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Enter &lt;A class="" title=WatIn href="http://watin.sourceforge.net/" target=_blank mce_href="http://watin.sourceforge.net/"&gt;WatiN&lt;/A&gt;&amp;nbsp;(pronounced as what-in); a fantastic open source API that leverages the browser to conduct web tests instead of emulating it. WatiN integrates easily with the VSTS framework and tests can be coded using C# or VB.NET. Currently WatiN uses IE7 but a &lt;A class="" title="WatIn Downloads" href="http://sourceforge.net/project/showfiles.php?group_id=167632" target=_blank mce_href="http://sourceforge.net/project/showfiles.php?group_id=167632"&gt;CTP&lt;/A&gt;&amp;nbsp;has been released that allows you to test with Firefox as well.&lt;/P&gt;
&lt;P mce_keep="true"&gt;The most impressive feature of WatiN is the level of access you have to the DOM. Web tests are able to find elements by id, index, name, text, CSS class, etc., iterate through collections of elements, and invoke any event.&lt;/P&gt;
&lt;P mce_keep="true"&gt;The following is an example and explanation of how to use WatiN using VSTS. The source code is available at the end of the post.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;U&gt;Environment Setup&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Download WatiN 1.3 &lt;A class="" title="WatIn Download" href="http://sourceforge.net/project/showfiles.php?group_id=167632" target=_blank mce_href="http://sourceforge.net/project/showfiles.php?group_id=167632"&gt;here&lt;/A&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Extract the files and if you are using Vista unblock the assemblies&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;U&gt;Creating the Project&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The downloadable source consists of a C# Test Project that contains a single Unit Test. Be sure to add a reference to the WatiNCore.dll and also copy the Interop.SHDocVw.dll into your /bin. The code I’ll be showing below will differ from the downloadable source to save some space.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;U&gt;The Test&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;I’ll show the test first and then explain what’s going on.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A href="http://weblogs.asp.net/blogs/alnurismail/121208/Fig1.jpg" mce_href="http://weblogs.asp.net/blogs/alnurismail/121208/Fig1.jpg"&gt;&lt;IMG src="http://weblogs.asp.net/blogs/alnurismail/121208/Fig1.jpg" border=0 mce_src="http://weblogs.asp.net/blogs/alnurismail/121208/Fig1.jpg"&gt;&lt;/A&gt;&lt;BR&gt;&lt;EM&gt;Figure 1 – “Hello World” test&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The test first creates an instance of IE and instructs it to navigate to live.com on a separate process. By creating the test on a separate process the session will not be stored across IE instances. The next instruction, which WatiN will call only after the entire page has loaded, queries the DOM to find a text field with the specified Id and once found enters the text. Next, the DOM is queried again to find a button with the specified name and the click event is triggered.&amp;nbsp; Finally we assert true if the page contains our search text, and our IE object is disposed.&lt;/P&gt;
&lt;P mce_keep="true"&gt;This test is very simplistic and very similar to the example test shown on the WatiN homepage except I’m searching live.com instead of google.com (Yes I like Kool-Aid!).&amp;nbsp; In my next post I’ll cover some more advanced scenarios and some tips and tricks to help make your own WatiN experience a little easier.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Source code &lt;A class="" title="Source Code" href="http://cid-e882c47b39adbc49.skydrive.live.com/browse.aspx/WatiN%7C_Prt1" target=_blank mce_href="http://cid-e882c47b39adbc49.skydrive.live.com/browse.aspx/WatiN%7C_Prt1 "&gt;here&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6780114" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alnurismail/archive/tags/ASP+.NET/default.aspx">ASP .NET</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/alnurismail/archive/tags/WatiN/default.aspx">WatiN</category></item></channel></rss>