<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Zubair.NET!</title><subtitle type="html" /><id>http://weblogs.asp.net/zubairahmed/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/zubairahmed/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2009-01-07T10:30:28Z</updated><entry><title>Getting started with Managed Extensibility Framework (MEF)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/11/29/getting-started-with-managed-extensibility-framework-mef.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/11/29/getting-started-with-managed-extensibility-framework-mef.aspx</id><published>2009-11-29T17:40:00Z</published><updated>2009-11-29T17:40:00Z</updated><content type="html">&lt;p&gt;Recently I got a chance to work with &lt;a href="http://www.wordpress.com/"&gt;WordPress&lt;/a&gt; and &lt;a href="http://drupal.org/"&gt;Drupal&lt;/a&gt;, those are the coolest PHP based blogging and content management systems out there, while I was impressed with the simplified installation and configuration, one thing that struck me was how simple it is to add plugins to the system. For instance I wanted a photogallery, so I downloaded the plug-in from &lt;a href="http://www.wordpress.com"&gt;WordPress.com&lt;/a&gt;, unzipped, dropped it in the &lt;u&gt;plugins&lt;/u&gt; folder, went to the Administration panel and there it was, the plug-in sitting right there ready to activate.&lt;/p&gt;  &lt;p&gt;Fortunately .NET now gets its own plug-in architecture framework in the form of &lt;a href="http://mef.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34838"&gt;Managed Extensibility Framework&lt;/a&gt; or MEF. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;MEF makes it really easy to build extensible .NET applications with just a few lines of code.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;em&gt;Here’s how.&lt;/em&gt;&lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In the application that needs to be extended you define a common interface that your plugins can implement.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IRule   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; DoIt();   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; }   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; Version { get; }   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; Description { get; }   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: 11px;
	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: 12px;
	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;Then you make a collection where all the plugins are stored and mark it with &lt;strong&gt;&lt;font color="#004080"&gt;&lt;em&gt;Import&lt;/em&gt;&lt;/font&gt;&lt;/strong&gt; or &lt;font color="#004080"&gt;&lt;em&gt;ImportMany&lt;/em&gt;&lt;/font&gt; attribute.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;[Import( &lt;span class="kwrd"&gt;typeof&lt;/span&gt;( IRule ) )]   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;internal&lt;/span&gt; IList&amp;lt;IRule&amp;gt;: _rules { get; set ;} &lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: 11px;
	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;/p&gt;

&lt;p&gt;Then all you need to do is write your plug-in that implements the above &lt;font color="#004080"&gt;&lt;em&gt;IRule&lt;/em&gt;&lt;/font&gt; interface that you defined in your extensible application and mark it with &lt;font color="#004080"&gt;&lt;em&gt;Export&lt;/em&gt;&lt;/font&gt; attribute.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;[Export( &lt;span class="kwrd"&gt;typeof&lt;/span&gt;( IRule ) )]   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;internal&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RuleInstance1 : IRule   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DoIt() {}   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    {   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Rule Instance 1&amp;quot;&lt;/span&gt;; }   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    }   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;  &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Version   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    {   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;1.0.0.0&amp;quot;&lt;/span&gt;; }   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    }   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;  &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Description   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    {   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        get { &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Some Rule Instance&amp;quot;&lt;/span&gt;; }   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;}   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;  &lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: 12px;
	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;With that only a few lines of code is required to load the plug-in into your extensible application.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init()   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    var catalog = &lt;span class="kwrd"&gt;new&lt;/span&gt; AggregateCatalog();   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    var container = &lt;span class="kwrd"&gt;new&lt;/span&gt; CompositionContainer( catalog );   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    var batch = &lt;span class="kwrd"&gt;new&lt;/span&gt; CompositionBatch();   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    batch.AddPart( &lt;span class="kwrd"&gt;this&lt;/span&gt; );   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    &lt;span class="rem"&gt;// because all our types are in the same assembly we simply use the current one.       &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    catalog.Catalogs.Add( &lt;span class="kwrd"&gt;new&lt;/span&gt; AssemblyCatalog( Assembly.GetExecutingAssembly() ) );   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    container.Compose( batch );   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; ( var rule &lt;span class="kwrd"&gt;in&lt;/span&gt; _rules )   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    {   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        Debug.WriteLine( rule.Name );   &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    }   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;}  &lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: 11px;
	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;/p&gt;

&lt;p&gt;While this simple example is great for exploring MEF and building plug-in that live in the same assembly, in the real world scenario your plugins will be built as part of a different solution or a project, do check out some of the resources below that demonstrate in detail how to leverage MEF in your applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://mef.codeplex.com" target="_blank"&gt;MEF on CodePlex&lt;/a&gt; – contains assemblies, source code and sample applications, do checkout the Silverlight grid sample.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://www.microsoftpdc.com/" target="_blank"&gt;PDC09&lt;/a&gt; demo 

  &lt;br /&gt;&lt;a href="http://twurl.nl/3cj8dp"&gt;http://twurl.nl/3cj8dp&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.hanselminutes.com" target="_blank"&gt;Hanselminutes&lt;/a&gt; podcast on MEF (with &lt;a href="http://www.google.com/url?q=http://blogs.msdn.com/gblock/&amp;amp;ei=168SS6r0KIro7AO99uTYBQ&amp;amp;sa=X&amp;amp;oi=spellmeleon_result&amp;amp;resnum=1&amp;amp;ct=result&amp;amp;ved=0CAcQhgIwAA&amp;amp;usg=AFQjCNGBwnoGIQnqnkPPHUgRwladqvN6wA"&gt;Glenn Block&lt;/a&gt;, the PM) 

  &lt;br /&gt;&lt;a href="http://twurl.nl/v6zoio"&gt;http://twurl.nl/v6zoio&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu"&gt;ScottGu&lt;/a&gt;’s awesome demo from PDC08 showing how MEF is used in the new VS2010 IDE to make it extensible, a must see. 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/brada/archive/2008/11/07/managed-extensibility-framework-mef-demo.aspx"&gt;http://blogs.msdn.com/brada...&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The code sample shown above is taken from here, uses the &lt;a href="http://mef.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34838"&gt;Preview 8&lt;/a&gt; drop of MEF on &lt;a href="http://www.codeplex.com"&gt;Codeplex&lt;/a&gt; 

  &lt;br /&gt;&lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2009/10/27/simple-kick-start-example-using-mef-preview-8.aspx?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+Devlicious+%28Devlicio.us%29"&gt;http://devlicio.us/blogs/derik_whittaker/archive..&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd460648(VS.100).aspx"&gt;MEF on MSDN&lt;/a&gt; – covers MEF in detail including the scenario to load multiple plugins and other details.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7266805" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author><category term="VS 2010" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/VS+2010/default.aspx" /><category term="MEF" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/MEF/default.aspx" /><category term="Extensibility" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/Extensibility/default.aspx" /></entry><entry><title>“Application Lifecycle Management in VS2010” session of TechiesUAE</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/11/21/application-lifecycle-management-in-vs2010-session-of-techiesuae.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/11/21/application-lifecycle-management-in-vs2010-session-of-techiesuae.aspx</id><published>2009-11-21T10:19:00Z</published><updated>2009-11-21T10:19:00Z</updated><content type="html">&lt;p&gt;I attended this session of TechiesUAE presented by &lt;a href="http://cid-d648a94eedb35657.profile.live.com" target="_blank"&gt;Rolf Eleveld&lt;/a&gt;. First he took us through the installation and configuration steps required to run Team Foundation Server 2010 and Visual Studio 2010 beta 2. &lt;/p&gt;  &lt;p&gt;Rolf then showed some of the new features in TFS 2010 version control and its integration with VS2010 including the web interface of TFS. &lt;/p&gt;  &lt;p&gt;Also during the session, one of the interesting tool that he showed us is the new &lt;a href="http://technet.microsoft.com/en-us/windows/dd320286.aspx" target="_blank"&gt;Problem Steps Recorder&lt;/a&gt; (or PSR) that ships with Windows 7. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/zubairahmed/psr_306E686C.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="psr" border="0" alt="psr" src="http://weblogs.asp.net/blogs/zubairahmed/psr_thumb_5D83553A.jpg" width="446" height="73" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This tool can help developers and IT Pros know the steps required to reproduce any problem to resolve it more quickly. For more info on it watch &lt;a href="http://technet.microsoft.com/en-us/windows/dd320286.aspx" target="_blank"&gt;this video&lt;/a&gt;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;During the session we also discussed the use of Entity Framework &amp;amp; Linq to Entities in the enterprise and also saw the demo of the interesting new &lt;strong&gt;Lab management &lt;/strong&gt;capabilities introduced in VSTS 2010. This helps testers test the software in a virtual environment and raise any bugs, the developers can then launch the virtual machine from the IDE and find all the rich information along with the check point link included in the bug, for more info on this read &lt;a href="http://blogs.msdn.com/somasegar/archive/2008/12/12/lab-management-in-vsts-2010.aspx" target="_blank"&gt;this post&lt;/a&gt; on &lt;strong&gt;Soma&lt;/strong&gt;’s blog. &lt;/p&gt;  &lt;p&gt;The session lasted more than 3 hours.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7262479" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author><category term="VS 2010" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/VS+2010/default.aspx" /><category term="TFS" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/TFS/default.aspx" /><category term="PSR" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/PSR/default.aspx" /></entry><entry><title>WCF Service Contract and XML Serialization</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/08/09/wcf-service-contract-and-xml-serialization.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/08/09/wcf-service-contract-and-xml-serialization.aspx</id><published>2009-08-09T07:13:00Z</published><updated>2009-08-09T07:13:00Z</updated><content type="html">&lt;p&gt;I am building a Service using the &lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644" mce_href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644" target="_blank"&gt;WCF REST Starter Kit&lt;/a&gt;. This Service contains a method that accepts a complex type as input, it then deserializes the object into it’s concrete type.&lt;/p&gt;  &lt;p&gt;Here’s how a service call looks like&lt;/p&gt;  &lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;   &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; (HttpClient client = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; HttpClient())&lt;br&gt;{&lt;br&gt;    RequestObject req = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; RequestObject { FirstName = &lt;span style="color: rgb(0, 96, 128);"&gt;"John"&lt;/span&gt;, LastName = &lt;span style="color: rgb(0, 96, 128);"&gt;"Doe"&lt;/span&gt;, Email=&lt;span style="color: rgb(0, 96, 128);"&gt;"johndoe@somecompany.com"&lt;/span&gt;};&lt;br&gt;&lt;br&gt;    HttpContent body = HttpContentExtensions.CreateXmlSerializable&amp;lt;RequestObject&amp;gt;(req);&lt;br&gt;&lt;br&gt;    HttpResponseMessage resp = client.Post(&lt;span style="color: rgb(0, 96, 128);"&gt;"http://localhost:1575/Web/Service.svc/SendMail"&lt;/span&gt;, body);&lt;br&gt;&lt;br&gt;    Response.Write(resp.Content.ReadAsString());&lt;br&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;What the above does is simply prepare a RequestObject, call a SendMail method on the service using the HttpClient, read and print the response, nothing fancy.&lt;/p&gt;

&lt;p&gt;Here’s how the service looks like&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
  &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;[WebHelp(Comment = &lt;span style="color: rgb(0, 96, 128);"&gt;"Sample description for SendMail"&lt;/span&gt;)]&lt;br&gt;[WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat =&lt;br&gt;WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml,UriTemplate = &lt;span style="color: rgb(0, 96, 128);"&gt;"SendMail"&lt;/span&gt;)]&lt;br&gt;[OperationContract]&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; RequestObject SendMail(RequestObject request)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; RequestObject()&lt;br&gt;    {&lt;br&gt;        FirstName = request.FirstName, LastName = request.LastName,Email = request.Email&lt;br&gt;    }; &lt;br&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Notice what I’m doing is preparing the same RequestObject and simply pass it as the response.&lt;/p&gt;

&lt;p&gt;As you’d expect I’m suppose to get the following response in the browser.&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
  &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;- &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;RequestObject&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;FirstName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;John&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;FirstName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; &lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;LastName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;Doe&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;LastName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; &lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Email&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;johndoe@somecompany.com&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Email&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt; &lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;RequestObject&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;But the response I receive is similar to this&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
  &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;RequestObject&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;FirstName&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;i:nil&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;LastNameName&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;i:nil&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Email&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;johndoe@somecompany.com&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Email&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;RequestObject&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After a few hours of trying it occurred to me that XML Serialization is done in the alphabetical order if no &lt;a href="http://msdn.microsoft.com/en-us/library/ms729813.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms729813.aspx" target="_blank"&gt;ordering is specified&lt;/a&gt; even if the properties in the class are not in the alpha-order. (arrgh. If only I had used the &lt;a href="http://blogs.msdn.com/endpoint/archive/2009/03/16/paste-xml-as-types-in-rest-starter-kit.aspx" mce_href="http://blogs.msdn.com/endpoint/archive/2009/03/16/paste-xml-as-types-in-rest-starter-kit.aspx" target="_blank"&gt;Paste XML as Type&lt;/a&gt; as demo’ed in &lt;a href="http://www.pluralsight.com/main/screencasts/screencast.aspx?id=httpclient-getting-started" mce_href="http://www.pluralsight.com/main/screencasts/screencast.aspx?id=httpclient-getting-started" target="_blank"&gt;this screencast&lt;/a&gt; by &lt;a href="http://www.pluralsight.com/main/instructor.aspx?name=aaron-skonnard" mce_href="http://www.pluralsight.com/main/instructor.aspx?name=aaron-skonnard" target="_blank"&gt;Aaron Skonnard&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;So to make it work I had to change the RequestObject class in both places to look like the following.&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;"&gt;
  &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; RequestObject&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Email { get; set; }&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; FirstName { get; set; }&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; LastName { get; set; }&lt;br&gt;}&lt;/pre&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7165033" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author><category term="XML" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/XML/default.aspx" /><category term="Serialization" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/Serialization/default.aspx" /><category term="WCF" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/WCF/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/C_2300_/default.aspx" /></entry><entry><title>VS 2010 Beta 1 and Functional UI Testing</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/05/14/vs-2010-beta-1-and-functional-ui-testing.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/05/14/vs-2010-beta-1-and-functional-ui-testing.aspx</id><published>2009-05-14T11:55:00Z</published><updated>2009-05-14T11:55:00Z</updated><content type="html">&lt;p&gt;I just watched a video over at Channel9 which explains how to leverage some of the &lt;a href="http://channel9.msdn.com/shows/10-4/10-4-Episode-18-Functional-UI-Testing/" target="_blank"&gt;UI Testing&lt;/a&gt; capabilities that are going to be introduced with VS 2010 beta 1 &lt;a href="http://tinyurl.com/rco494" target="_blank"&gt;expected next week&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Visual Studio had testing capabilities for C# code for a long but now I’m glad to see for the first time an integrated UI testing built right into VS 2010 IDE. In particular I like the option to store the tests in the database and be able to run them automatically. &lt;/p&gt;  &lt;p&gt;See it for yourself, there is also a &lt;a href="http://www.visitmix.com" target="_blank"&gt;Mix09&lt;/a&gt; video &lt;a href="http://videos.visitmix.com/MIX09/T83M" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7086835" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author><category term="VS 2010" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/VS+2010/default.aspx" /><category term="UI Testing" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/UI+Testing/default.aspx" /></entry><entry><title>Return JSON objects the right way</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/04/29/return-json-objects-the-right-way.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/04/29/return-json-objects-the-right-way.aspx</id><published>2009-04-29T08:12:54Z</published><updated>2009-04-29T08:12:54Z</updated><content type="html">&lt;p&gt;Today I experienced a weird behavior when I was passing &lt;a href="http://www.json.org/" target="_blank"&gt;JSON&lt;/a&gt; string back to a jQuery call using an Ajax-enabled WCF Service.&lt;/p&gt;  &lt;p&gt;My code looked something like this.&lt;/p&gt;  &lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = &lt;span style="color: #006080"&gt;&amp;quot;/GetJson&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; GetJson()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JavaScriptSerializer().Serialize(MyCustomObject)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The problem with above code is that the string returned is escaped and enclosed with inverted commas that for some reason was not handled properly using jQuery that looked like this.&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;“[{\&amp;quot;Id\&amp;quot;:1,\&amp;quot;SomeKey\&amp;quot;:\&amp;quot;SomeMoreText\&amp;quot;}]”&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Not sure what I was missing and while there is a &lt;a href="http://nayyeri.net/blog/using-jsonresult-in-asp-net-mvc-ajax/" target="_blank"&gt;JsonResult&lt;/a&gt; action in &lt;a href="http://www.asp.net/mvc/" target="_blank"&gt;ASP.NET MVC&lt;/a&gt; with a .svc there’s nothing that I could use (or may be there is). &lt;/p&gt;

&lt;p&gt;To fix it I changed the method like this. &lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = &lt;span style="color: #006080"&gt;&amp;quot;/GetJson&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; System.IO.Stream GetJson()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] resultBytes = System.Text.Encoding.UTF8.GetBytes(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JavaScriptSerializer().Serialize(MyCustomObject));&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   WebOperationContext.Current.OutgoingResponse.ContentType = &lt;span style="color: #006080"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;   &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MemoryStream(resultBytes); &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here’s how Json is returned.&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;[{&amp;quot;Id&amp;quot;:1,&amp;quot;SomeKey&amp;quot;:&amp;quot;SomeMoreText&amp;quot;}]&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7064420" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author></entry><entry><title>Don’t use UriTemplate = "/MethodName/Param1/{Param1}/Param2/{JsonObject} for Json input with WCF Service</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/04/12/don-t-use-uritemplate-quot-methodname-param1-param1-param2-jsonobject-for-json-input-with-wcf-service.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/04/12/don-t-use-uritemplate-quot-methodname-param1-param1-param2-jsonobject-for-json-input-with-wcf-service.aspx</id><published>2009-04-12T12:58:00Z</published><updated>2009-04-12T12:58:00Z</updated><content type="html">&lt;p&gt;When building Ajax-enabled WCF service that expect a Json object as input then the following would not work&lt;/p&gt;  &lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = &lt;span style="color: #006080"&gt;&amp;quot;/Methodname/jsonvariable/{jsonvariable}/param2/{param2}&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; MethodName(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; jsonvariable, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; param2)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Where &lt;u&gt;jsonvariable&lt;/u&gt; is a json object passed through jQuery (or ASP.NET Ajax) to a WCF service that looks like this &lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff"&gt;[{&amp;quot;Name&amp;quot;:&amp;quot;za&amp;quot;,&amp;quot;Email&amp;quot;:zubairdotnet@hotmail.com}]&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;After spending a while I figured out that the following &lt;u&gt;UriTemplate &lt;/u&gt;should be used instead&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = &lt;span style="color: #006080"&gt;&amp;quot;/Methodname/?jsonvariable={jsonvariable}&amp;amp;param2={param2}&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; MethodName(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; jsonvariable, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; param2)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; 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: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7064417" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author></entry><entry><title>Using Regular Expressions to Rename Textbox IDs</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/zubairahmed/archive/2009/01/07/using-regular-expressions-to-rename-textbox-ids.aspx" /><id>http://weblogs.asp.net/zubairahmed/archive/2009/01/07/using-regular-expressions-to-rename-textbox-ids.aspx</id><published>2009-01-07T06:30:28Z</published><updated>2009-01-07T06:30:28Z</updated><content type="html">&lt;p&gt;How can you use regular expression in Find and Replace in Visual Studio to use the Textbox IDs same as your Column name in the Eval statement?&lt;/p&gt;  &lt;p&gt;Consider the following two textboxes and there are couple of textboxes like them in the form&lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;cmpst:Textbox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;txtAppNo&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;lt;%#Eval(&amp;quot;AppDate&amp;quot;) %&amp;gt;'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;cmpst:Textbox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;txtAppNo&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;lt;%#Eval(&amp;quot;NIN&amp;quot;) %&amp;gt;'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You want to convert the IDs of the above textboxes as following&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;cmpst:Textbox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;txtAppDate&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;lt;%#Eval(&amp;quot;AppDate&amp;quot;) %&amp;gt;'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;cmpst:Textbox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;txtNIN&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;='&amp;lt;%#Eval(&amp;quot;NIN&amp;quot;) %&amp;gt;'&lt;/span&gt; &lt;span style="color: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;I took me a while to get this regular expression right, so I'm posting it here for reuse, here's how&lt;/p&gt;

&lt;p&gt;Find&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;ID=\&amp;quot;txt(.*)\&amp;quot; Text=\'\&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;\%\#Eval\(\&amp;quot;{(.*)}\&amp;quot;\)&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Replace&lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;ID=&amp;quot;txt\1&amp;quot; Text='&lt;span style="background-color: #ffff00"&gt;&amp;lt;%&lt;/span&gt;#Eval(&amp;quot;\1&amp;quot;)&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6823262" width="1" height="1"&gt;</content><author><name>zubairdotnet</name><uri>http://weblogs.asp.net/members/zubairdotnet.aspx</uri></author><category term="Regular Expression" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/Regular+Expression/default.aspx" /><category term="Visual Studio" scheme="http://weblogs.asp.net/zubairahmed/archive/tags/Visual+Studio/default.aspx" /></entry></feed>
