Tip #1 - Using AjaxPro.AjaxNoTypeUsage

Michael Schwarz on Thursday, April 12, 2007

If you want to hide name and assembly details of classes you return in your AjaxMethod simple add the AjaxPro.AjaxNoTypeUsage attribute as meta information:

[AjaxPro.AjaxNoTypeUsage]<span class="kwrd">public</span> <span class="kwrd">class</span> MyReturnValue
{
<span class="kwrd">public</span> <span class="kwrd">string</span> FirstName;
<span class="kwrd">public</span> <span class="kwrd">int</span> Age;
<span class="kwrd">public</span> <span class="kwrd">bool</span> IsMarried;
}</pre>

Adding this will remove the JSON property __type from the result value. You will save some bytes (i.e. if used in arrays) and get rid of internal information of your namespace and assembly name conventions.

<pre class="csharpcode"><span class="rem">// before</span>
var json = {__type:<span class="str">"MyNamespace.MyClass,MyAssemnly"</span>,<br> Firstname:<span class="str">"Michael"</span>,Age:29,IsMarried:<span class="kwrd">true</span>};
<span class="rem">// after</span>
var json = {Firstname:<span class="str">"Michael"</span>,Age:29,IsMarried:<span class="kwrd">true</span>};</pre>