﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-GHOST的Blog</title><link>http://www.cnblogs.com/ghost1980/</link><description>坚持就是胜利！</description><language>zh-cn</language><lastBuildDate>Tue, 09 Feb 2010 20:00:00 GMT</lastBuildDate><pubDate>Tue, 09 Feb 2010 20:00:00 GMT</pubDate><ttl>60</ttl><item><title>最近写的一个上传的类,借鉴了网上一些朋友的好建议,请大家指教。</title><link>http://www.cnblogs.com/ghost1980/archive/2006/01/17/318942.html</link><dc:creator>ghost1980</dc:creator><author>ghost1980</author><pubDate>Tue, 17 Jan 2006 06:08:00 GMT</pubDate><guid>http://www.cnblogs.com/ghost1980/archive/2006/01/17/318942.html</guid><description><![CDATA[<p>阅读: 1490 评论: 6 作者: <a href="http://www.cnblogs.com/ghost1980/" target="_blank">ghost1980</a> 发表于 2006-01-17 14:08 <a href="http://www.cnblogs.com/ghost1980/archive/2006/01/17/318942.html" target="_blank">原文链接</a></p><P>using System;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Data;<BR>using System.Drawing;<BR>using System.Web;<BR>using System.Web.SessionState;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.HtmlControls;<BR>using System.IO;<BR>using System.Runtime.Remoting.Messaging;<BR>namespace uploadfiles<BR>{<BR>&nbsp;/// &lt;summary&gt;<BR>&nbsp;/// ClassUpload 的摘要说明。<BR>&nbsp;/// &lt;/summary&gt;<BR>&nbsp;/*<BR>&nbsp; wenconfig中添加元素<BR>&nbsp; &lt;httpRuntime maxRequestLength="1048576" executionTimeout="3600" /&gt;<BR>&nbsp; &lt;!-- maxRequestLength：指示 ASP.NET <BR>&nbsp;&nbsp;支持的HTTP方式上载的最大字节数。该限制可用于防止因用户将大量文件传递到该服务器而导致的拒绝服务攻击。指定的大小以 KB 为单位。默认值为 4096 KB <BR>&nbsp;&nbsp;(4 MB)。executionTimeout：指示在被 ASP.NET 自动关闭前，允许执行请求的最大秒数。在当文件超出指定的大小时，如果浏览器中会产生 <BR>&nbsp;&nbsp;DNS 错误或者出现服务不可得到的情况，也请修改以上的配置，把配置数加大。 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --&gt;<BR>&nbsp; */<BR>&nbsp;/*<BR>&nbsp; Machine.config中添加元素<BR>&nbsp; &lt;processModel <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enable="true"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timeout="15" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; idleTimeout="25"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shutdownTimeout="5"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; requestLimit="1000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; requestQueueLimit="500"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; responseDeadlockInterval="00:03:00"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; responseRestartDeadlockInterval="Infinite"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memoryLimit="80"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webGarden="true"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxWorkerThreads="25"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxIoThreads="25"/&gt;<BR>&nbsp;&nbsp; &lt;!-- <BR>&nbsp;&nbsp;上载大文件时，还可能会收到以下错误信息：&lt;/P&gt;&lt;XMP&gt;&nbsp;aspnet_wp.exe (PID: 1520) 被回收，因为内存消耗超过了 460 MB（可用 RAM 的百分之 60）。<BR>&nbsp;&lt;/XMP&gt;<BR>&nbsp;&lt;P&gt;如果遇到此错误信息，请增加应用程序的 Machine.config 文件的 &lt;processModel&gt;元素中 memoryLimit 属性的值。 <BR>&nbsp;&nbsp;&nbsp; --&gt;<BR>&nbsp; */<BR>&nbsp;public class ClassUpload<BR>&nbsp;{<BR>&nbsp;&nbsp;public ClassUpload()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;// TODO: 在此处添加构造函数逻辑<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;private System.IO.MemoryStream m;<BR>&nbsp;&nbsp;private System.IO.Stream fs;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string _filename;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //上传文件扩展名<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int _maxlength;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //获取上传文件最大长度(字节)<BR>&nbsp;&nbsp;private string _FilePath;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //获取本地上传文件路径<BR>&nbsp;&nbsp;private int&nbsp;&nbsp;&nbsp; _length = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //保存文件长度(字节)<BR>&nbsp;&nbsp;private string _savepath;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //获取保存路径<BR>&nbsp;&nbsp;private string _savename;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //重命名后的上传文件<BR>&nbsp;&nbsp;private string _fullpath;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //上传文件的完整目录<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;/// &lt;summary&gt;<BR>&nbsp;&nbsp;/// 上传文件成功后文件的长度(字节)<BR>&nbsp;&nbsp;/// &lt;/summary&gt;<BR>&nbsp;&nbsp;public int length<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return _length;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 获取保存路径<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<BR>&nbsp;&nbsp;public string savepath<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return _savepath;</P>
<P>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 获取重命名后的上传文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<BR>&nbsp;&nbsp;public string savename<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return _savename;</P>
<P>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;/// &lt;summary&gt;<BR>&nbsp;&nbsp;/// 获取上传后文件的完整目录<BR>&nbsp;&nbsp;/// &lt;/summary&gt;<BR>&nbsp;&nbsp;public string fullpath<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return _fullpath;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; /// 获取本地上传文件路径<BR>&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<BR>&nbsp;&nbsp;public string filepath<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;get<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return _FilePath;</P>
<P>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;/// &lt;summary&gt;<BR>&nbsp;&nbsp;/// 上传文件方法<BR>&nbsp;&nbsp;/// &lt;/summary&gt;<BR>&nbsp;&nbsp;/// &lt;param name="MyFile"&gt;System.Web.UI.HtmlControls.HtmlInputFile&lt;/param&gt;<BR>&nbsp;&nbsp;/// &lt;param name="savepath"&gt;设置保存上传文件的路径&lt;/param&gt;<BR>&nbsp;&nbsp;/// &lt;param name="maxlength"&gt;设置上传文件的最大长度&lt;/param&gt;<BR>&nbsp;&nbsp;public string upload(System.Web.UI.HtmlControls.HtmlInputFile MyFile,string savepath,int maxlength)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;this._savepath = savepath;<BR>&nbsp;&nbsp;&nbsp;this._maxlength = maxlength;<BR>&nbsp;&nbsp;&nbsp;//得到上载文件信息和文件流<BR>&nbsp;&nbsp;&nbsp;if(MyFile.PostedFile != null)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;System.Web.HttpFileCollection oFiles;<BR>&nbsp;&nbsp;&nbsp;&nbsp;oFiles = System.Web.HttpContext.Current.Request.Files;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;if(oFiles.Count &lt; 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "请选择文件!";<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;_FilePath = oFiles[0].FileName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(_FilePath == "" || _FilePath == null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "请选择一个文件!";<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;_filename = "."+_FilePath.Substring(_FilePath.LastIndexOf(".")+1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;//_contentlength = oFiles[0].ContentLength.ToString();</P>
<P style="FONT-SIZE: 8pt">&nbsp;&nbsp;&nbsp;&nbsp;//Response.Write(FileName+FilePath);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(oFiles[0].ContentLength&gt;this._maxlength)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "上传文件长度过大";<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//处理上载的文件流信息。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[] b = new byte[oFiles[0].ContentLength];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//System.IO.Stream fs;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fs = (System.IO.Stream)oFiles[0].InputStream;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fs.Read(b, 0, oFiles[0].ContentLength);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//调用处理内存流方法UploadFile<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return this.UploadFile(b,this._filename,this._savepath);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//int value = Convert.ToInt32(asy.AsyncState);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch(Exception ex)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Response.Write(ex.Message);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ex.Message;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;finally<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fs.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;//Response.Write("请选择文件");<BR>&nbsp;&nbsp;&nbsp;&nbsp;return "请选择文件";<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}</P>
<P>&nbsp;&nbsp;private string UploadFile(byte[] fs,string FileName,string savepath)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;try<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//定义并实例化一个内存流，以存放提交上来的字节数组。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m = new MemoryStream(fs);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this._length = fs.Length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //System.Web.HttpContext.Current.Server.MapPath(".") + @"<A href="file://images/">\\images\</A>"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//定义实际文件对象，保存上载的文件。<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;this._fullpath = this._savepath+ names()+FileName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileStream f = new FileStream(this._fullpath, FileMode.Create);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this._savename = names()+FileName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//把内内存里的数据写入物理文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m.WriteTo(f);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f = null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m = null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;return "文件已经上传成功!";<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;catch(Exception ex)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;return ex.Message;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;//生成 (年,月,日,时,分,秒)+随机数的文件名<BR>&nbsp;&nbsp;private string names()<BR>&nbsp;&nbsp;{&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;Random rm = new Random(System.Environment.TickCount);<BR>&nbsp;&nbsp;&nbsp;return System.DateTime.Now.ToString("yyyyMMddhhmmss")+rm.Next(1000,9999).ToString();<BR>&nbsp;&nbsp;}</P>
<P>&nbsp;}<BR>}<BR></P><img src="http://www.cnblogs.com/ghost1980/aggbug/318942.html?type=1" width="1" height="1" alt=""/><p>评论: 6　<a href="http://www.cnblogs.com/ghost1980/archive/2006/01/17/318942.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/ghost1980/archive/2006/01/17/318942.html#commentform" target="_blank">发表评论</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/56793/" target="_blank">知名扩展 Firebug 的简化版登陆 Chrome</a><span style="color:gray">(2010-02-09 22:59)</span><br/>· <a href="http://news.cnblogs.com/n/56792/" target="_blank">Google 悄悄地启用 1e100.net，打枪地不要</a><span style="color:gray">(2010-02-09 22:57)</span><br/>· <a href="http://news.cnblogs.com/n/56791/" target="_blank">从 Google 代码库找到的好东西</a><span style="color:gray">(2010-02-09 22:46)</span><br/>· <a href="http://news.cnblogs.com/n/56789/" target="_blank">苹果在线商店临时关闭 或将推新Macbook</a><span style="color:gray">(2010-02-09 22:39)</span><br/>· <a href="http://news.cnblogs.com/n/56788/" target="_blank">豆瓣网推出豆瓣电台iPhone客户端</a><span style="color:gray">(2010-02-09 21:51)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/56782/" target="_blank">2010年2月编程语言排行榜</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>AJAX .Net Wrapper usage guide</title><link>http://www.cnblogs.com/ghost1980/archive/2005/10/31/265659.html</link><dc:creator>ghost1980</dc:creator><author>ghost1980</author><pubDate>Mon, 31 Oct 2005 09:26:00 GMT</pubDate><guid>http://www.cnblogs.com/ghost1980/archive/2005/10/31/265659.html</guid><description><![CDATA[<p>阅读: 884 评论: 10 作者: <a href="http://www.cnblogs.com/ghost1980/" target="_blank">ghost1980</a> 发表于 2005-10-31 17:26 <a href="http://www.cnblogs.com/ghost1980/archive/2005/10/31/265659.html" target="_blank">原文链接</a></p><H2 style="MARGIN: 12pt 0cm 3pt"><A name=_Toc104130686><SPAN lang=EN-US><FONT style="FONT-SIZE: 12pt" face=Arial>Background</FONT></SPAN></A></H2><SPAN lang=EN-US>Asynchronous JavaScript and XML (AJAX) has recently become the craze thanks, in no small part, to Google&#8217;s usage of it in <A href="http://www.google.com/webhp?complete=1&amp;hl=en">Google Suggest</A> as well as <A href="http://maps.google.com/">Google Maps</A>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In ASP.Net terms, <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place> allows server-side processing to occur without requiring postback, thus enabling clients (browsers) with rich server-side capabilities.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In other words it provides a framework for asynchronously dispatching and processing requests and responses from the server. <st1:City w:st="on">AJAX</st1:City> leverages a number of existing technologies, which aren't particularly new, however fondness for what these technologies have to offer (collectively, they are <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City>) has recently soared.<BR></SPAN><SPAN lang=EN-US>Enter <A href="http://weblogs.asp.net/mschwarz/">Michael Schwarz</A>'s <st1:City w:st="on">AJAX</st1:City> .Net wrapper which allows ASP.Net developers to quickly and easily deploy pages capable of easily capitalizing on <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Users should be cautioned that the wrapper is early in development, and as such isn't fully matured.<SPAN style="mso-spacerun: yes">&nbsp; <BR></SPAN></SPAN><SPAN lang=EN-US>It should be pointed out that technologies such as <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> are very likely going to lead to violations of layered architectures (N-Tier).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>My opinion is that <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> increases the likelihood that the presentation logic layer (or worse, the business layer) will leak into the presentation layer.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Strict architects, like me, might cringe at this notion.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I feel that even if <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> is used in a manor which slightly violates layer boundaries, the payoffs are well worth it. Of course, that's something you'll need to look at for your specific project and environment.<BR>&nbsp; 
<TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid #993300 1.0pt; mso-yfti-tbllook: 480; mso-padding-alt: 10.8pt 5.75pt 10.8pt 5.75pt; mso-border-insideh: 1.0pt solid #993300; mso-border-insidev: 1.0pt solid #993300" cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: #993300 1pt solid; WIDTH: 36.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid" vAlign=top width=48>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><o:p><IMG height=33 hspace=0 src="http://www.cnblogs.com/images/cnblogs_com/ghost1980/clip_image001.jpg" width=33></o:p></SPAN></P></TD>
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: medium none; WIDTH: 406.55pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid; mso-border-left-alt: solid #993300 1.0pt" vAlign=top width=542>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt">To learn more about <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place>, visit:<BR><A href="http://en.wikipedia.org/wiki/AJAX">http://en.wikipedia.org/wiki/AJAX</A><BR><A href="http://www.adaptivepath.com/publications/essays/archives/000385.php">http://www.adaptivepath.com/publications/essays/archives/000385.php</A><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE><BR>
<H2 style="MARGIN: 12pt 0cm 3pt"><A name=_Toc104130687><SPAN lang=EN-US><FONT style="FONT-SIZE: 12pt" face=Arial>How it works - Overview</FONT></SPAN></A></H2><st1:place w:st="on"><st1:City w:st="on"><SPAN lang=EN-US>AJAX</SPAN></st1:City></st1:place><SPAN lang=EN-US> relies on a broker to dispatch and process requests to and from the server.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For this task, the .Net wrapper relies on the client-side </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">XmlHttpRequest</SPAN></SPAN><SPAN lang=EN-US> object. The </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">XmlHttpRequest</SPAN></SPAN><SPAN lang=EN-US> object is well supported by most browsers, making it the solution of choice.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Since the goal of the wrapper is to hide the implementation of </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">XmlHttpRequest</SPAN></SPAN><SPAN lang=EN-US>, we'll forgo any detailed discussion about it.<BR></SPAN><SPAN lang=EN-US>The wrapper itself works by marking .Net functions as <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> methods.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Once marked, <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place> creates corresponding JavaScript functions which can be called client-side (liky any JavaScript functions) and that serve as proxies, using </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">XmlHttpRequest</SPAN></SPAN><SPAN lang=EN-US>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>These proxies map back to the server-side function.<BR></SPAN><SPAN lang=EN-US>Complicated?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It isn't.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Let's look at a simplified example.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Given the .Net function:<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">VB.Net</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_15_132_Open_Image onclick="this.style.display='none'; Codehighlighter1_15_132_Open_Text.style.display='none'; Codehighlighter1_15_132_Closed_Image.style.display='inline'; Codehighlighter1_15_132_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_15_132_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_15_132_Closed_Text.style.display='none'; Codehighlighter1_15_132_Open_Image.style.display='inline'; Codehighlighter1_15_132_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_15_132_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Function&nbsp;Add()</SPAN><SPAN id=Codehighlighter1_15_132_Open_Text><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;Add(firstNumber&nbsp;</SPAN><SPAN style="COLOR: #0000ff">as</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">integer</SPAN><SPAN style="COLOR: #000000">,&nbsp;secondNumber&nbsp;</SPAN><SPAN style="COLOR: #0000ff">as</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">integer</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">as</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">integer</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">end&nbsp;sub</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN></DIV></SPAN><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">C#&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;Add(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber)<BR><IMG id=Codehighlighter1_56_96_Open_Image onclick="this.style.display='none'; Codehighlighter1_56_96_Open_Text.style.display='none'; Codehighlighter1_56_96_Closed_Image.style.display='inline'; Codehighlighter1_56_96_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_56_96_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_56_96_Closed_Text.style.display='none'; Codehighlighter1_56_96_Open_Image.style.display='inline'; Codehighlighter1_56_96_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_56_96_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_56_96_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US><BR>The <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place> .Net wrapper will automatically create a JavaScript function called "Add" which takes two parameters.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When this function is called using JavaScript (on the client), the request will be passed to the server and the return value back to the client.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN>
<H2><A name=_Toc104130688><SPAN lang=EN-US style="FONT-SIZE: 12pt">Initial Setup</SPAN></A></H2>
<P class=MsoNormal><SPAN lang=EN-US>We'll first go through the steps of "installing" the .dll for use in your project.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you know how to add a reference to a .dll file, skip this section.<BR></SPAN><SPAN lang=EN-US>First, if you don&#8217;t already have it, download the latest version of <A href="http://ajax.schwarz-interactive.de/download/ajax.zip">AJAX</A>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Unzip the downloaded file and place the <I style="mso-bidi-font-style: normal">ajax.dll</I> within a <I style="mso-bidi-font-style: normal">ref</I> folder of your project.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In Visual Studio.Net, right click the "References" node in the <I style="mso-bidi-font-style: normal">Solution Explorer</I> and select <I style="mso-bidi-font-style: normal">Add Reference</I>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In the newly opened dialog, click <I style="mso-bidi-font-style: normal">Browse</I> and navigate to the <I style="mso-bidi-font-style: normal">ref/ajax.dll</I> file.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Click <I style="mso-bidi-font-style: normal">Open</I> followed by <I style="mso-bidi-font-style: normal">Ok</I>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You are now ready to start programming with the <st1:place w:st="on"><st1:City w:st="on">AJAX</st1:City></st1:place> .Net wrapper.</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid #993300 1.0pt; mso-yfti-tbllook: 480; mso-padding-alt: 10.8pt 5.75pt 10.8pt 5.75pt; mso-border-insideh: 1.0pt solid #993300; mso-border-insidev: 1.0pt solid #993300" cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: #993300 1pt solid; WIDTH: 36.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid" vAlign=top width=48>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 24.75pt; HEIGHT: 24.75pt" type="#_x0000_t75"><v:imagedata o:title="info" src="file:///C:\DOCUME~1\wangaw\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><IMG height=33 hspace=0 src="http://www.cnblogs.com/images/cnblogs_com/ghost1980/clip_image001.jpg" width=33></v:imagedata></v:shape><o:p></o:p></SPAN></P></TD>
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: medium none; WIDTH: 406.55pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid; mso-border-left-alt: solid #993300 1.0pt" vAlign=top width=542>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt">If you&#8217;re having difficulty setting up the reference, check out:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingremovingreferences.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingremovingreferences.asp</A><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P class=MsoNormal><A name=_Toc104130689><SPAN lang=EN-US style="FONT-SIZE: 12pt"><STRONG style="FONT-SIZE: 12pt">Setting up the HttpHandler</STRONG></SPAN></A></P>
<P class=MsoNormal><SPAN lang=EN-US>The first step necessary to make everything work is to set up the wrapper's </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">HttpHandler</SPAN></SPAN><SPAN lang=EN-US> in the <I style="mso-bidi-font-style: normal">web.config</I>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Without going into detailed explanation of what and how </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">HttpHandlers</SPAN></SPAN><SPAN lang=EN-US> work, it's sufficient to know that that they are used to process ASP.Net requests.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, all requests for <I style="mso-bidi-font-style: normal">*.aspx</I> pages are handled by the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">System.Web.UI.PageHandlerFactory</SPAN></SPAN><SPAN lang=EN-US> class.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Similarly we'll make all requests to <st1:place w:st="on"><st1:City w:st="on"><I style="mso-bidi-font-style: normal">ajax</I></st1:City></st1:place><I style="mso-bidi-font-style: normal">/*.ashx</I> handled by the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Ajax.PageHandlerFactory</SPAN></SPAN><SPAN lang=EN-US>:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">configuration</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">system</SPAN><SPAN style="COLOR: #ff0000">.web</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">httpHandlers</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">add&nbsp;</SPAN><SPAN style="COLOR: #ff0000">verb</SPAN><SPAN style="COLOR: #0000ff">="POST,GET"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;path</SPAN><SPAN style="COLOR: #0000ff">="ajax/*.ashx"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="Ajax.PageHandlerFactory,&nbsp;Ajax"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">httpHandlers</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<IMG src="http://www.cnblogs.com/Images/dot.gif"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">system</SPAN><SPAN style="COLOR: #ff0000">.web</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">configuration</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US><BR>The above code basically tells ASP.Net that any requests made that match the specified path (<st1:place w:st="on"><st1:City w:st="on"><I>ajax</I></st1:City></st1:place><I>/*.ashx</I>) are to be handled by </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Ajax.PageHandlerFactory</SPAN></SPAN><SPAN lang=EN-US>, instead of the default handler factory.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You don&#8217;t need to create an <st1:place w:st="on"><st1:City w:st="on"><I style="mso-bidi-font-style: normal">ajax</I></st1:City></st1:place><I style="mso-bidi-font-style: normal"> </I>subdirectory, this is a mythical directory simply used so that other </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">HttpHandlers</SPAN></SPAN><SPAN lang=EN-US> can use the <I style="mso-bidi-font-style: normal">.ashx</I> extension with their own made-up subdirectories.<BR><BR></SPAN><A name=_Toc104130690><SPAN lang=EN-US><STRONG style="FONT-SIZE: 12pt">Setting up the Page</STRONG></SPAN></A> 
<P class=MsoNormal><SPAN lang=EN-US>We are now ready to start coding.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Create a new page, or open an existing one and in the code behind file, add the following code in the Page_Load event:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">vb.net</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_15_222_Open_Image onclick="this.style.display='none'; Codehighlighter1_15_222_Open_Text.style.display='none'; Codehighlighter1_15_222_Closed_Image.style.display='inline'; Codehighlighter1_15_222_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_15_222_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_15_222_Closed_Text.style.display='none'; Codehighlighter1_15_222_Open_Image.style.display='inline'; Codehighlighter1_15_222_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_15_222_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Class&nbsp;Index</SPAN><SPAN id=Codehighlighter1_15_222_Open_Text><SPAN style="COLOR: #0000ff">Class</SPAN><SPAN style="COLOR: #000000">&nbsp;Index&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Inherits</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Web.UI.Page<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_69_205_Open_Image onclick="this.style.display='none'; Codehighlighter1_69_205_Open_Text.style.display='none'; Codehighlighter1_69_205_Closed_Image.style.display='inline'; Codehighlighter1_69_205_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_69_205_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_69_205_Closed_Text.style.display='none'; Codehighlighter1_69_205_Open_Image.style.display='inline'; Codehighlighter1_69_205_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_69_205_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Sub&nbsp;Page_Load()</SPAN><SPAN id=Codehighlighter1_69_205_Open_Text><SPAN style="COLOR: #0000ff">Sub</SPAN><SPAN style="COLOR: #000000">&nbsp;Page_Load(sender&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Object</SPAN><SPAN style="COLOR: #000000">,&nbsp;e&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;EventArgs)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Handles</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">MyBase</SPAN><SPAN style="COLOR: #000000">.Load<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;Ajax.Utility.RegisterTypeForAjax(</SPAN><SPAN style="COLOR: #0000ff">GetType</SPAN><SPAN style="COLOR: #000000">(Index))<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">end&nbsp;sub</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Class</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">C#</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_44_191_Open_Image onclick="this.style.display='none'; Codehighlighter1_44_191_Open_Text.style.display='none'; Codehighlighter1_44_191_Closed_Image.style.display='inline'; Codehighlighter1_44_191_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_44_191_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_44_191_Closed_Text.style.display='none'; Codehighlighter1_44_191_Open_Image.style.display='inline'; Codehighlighter1_44_191_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Index&nbsp;:&nbsp;System.Web.UI.Page</SPAN><SPAN id=Codehighlighter1_44_191_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_44_191_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_99_178_Open_Image onclick="this.style.display='none'; Codehighlighter1_99_178_Open_Text.style.display='none'; Codehighlighter1_99_178_Closed_Image.style.display='inline'; Codehighlighter1_99_178_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_99_178_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_99_178_Closed_Text.style.display='none'; Codehighlighter1_99_178_Open_Image.style.display='inline'; Codehighlighter1_99_178_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Page_Load(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;sender,&nbsp;EventArgs&nbsp;e)</SPAN><SPAN id=Codehighlighter1_99_178_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_99_178_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ajax.Utility.RegisterTypeForAjax(</SPAN><SPAN style="COLOR: #0000ff">typeof</SPAN><SPAN style="COLOR: #000000">(Index));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>The call to </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">RegisterTypeForAjax</SPAN></SPAN><SPAN lang=EN-US> emits the following JavaScript on the page (alternatively, you could manually place the following two lines on the page):<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">script&nbsp;language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">javascript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;src</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ajax/common.ashx</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;&lt;/</SPAN><SPAN style="COLOR: #000000">script</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">script&nbsp;language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">javascript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>src</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ajax/NAMESPACE.PAGECLASS,ASSEMBLYNAME.ashx</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;&lt;/</SPAN><SPAN style="COLOR: #000000">script</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US><BR>Where the bolded parts have the following meaning: </SPAN>
<TABLE class=Table style="BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 95.4pt; PADDING-TOP: 0cm" vAlign=top width=127>
<P class=Code-Inline><SPAN lang=EN-US>NAMESPACE.PAGECLASS</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 347.4pt; PADDING-TOP: 0cm" vAlign=top width=463>
<P class=MsoNormal><SPAN lang=EN-US>The namespace and class of the current page</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US>(this will typically be the value of the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Inherits</SPAN></SPAN><SPAN lang=EN-US> attribute in the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">@Page </SPAN></SPAN><SPAN lang=EN-US>directive)</SPAN></P></TD></TR>
<TR style="mso-yfti-irow: 1; mso-yfti-lastrow: yes">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 95.4pt; PADDING-TOP: 0cm" vAlign=top width=127>
<P class=Code-Inline><SPAN lang=EN-US>ASSEMBLYNAME</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 347.4pt; PADDING-TOP: 0cm" vAlign=top width=463>
<P class=MsoNormal><SPAN lang=EN-US>The name of the assembly the current page is part of</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US>(this will typically be the name of your project)</SPAN></P></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN lang=EN-US>Bellow is a sample output for the <I style="mso-bidi-font-style: normal">sample.aspx</I> page in an </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxPlay</SPAN></SPAN><SPAN lang=EN-US> project:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_2_67_Open_Image onclick="this.style.display='none'; Codehighlighter1_2_67_Open_Text.style.display='none'; Codehighlighter1_2_67_Closed_Image.style.display='inline'; Codehighlighter1_2_67_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2_67_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2_67_Closed_Text.style.display='none'; Codehighlighter1_2_67_Open_Image.style.display='inline'; Codehighlighter1_2_67_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_2_67_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2_67_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@&nbsp;Page&nbsp;Inherits</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">AjaxPlay.Sample</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;Codebehind</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sample.aspx.cs</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;<IMG src="http://www.cnblogs.com/Images/dot.gif">&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="javascript"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;src</SPAN><SPAN style="COLOR: #0000ff">="ajax/common.ashx"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="javascript"</SPAN><SPAN style="COLOR: #ff0000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src</SPAN><SPAN style="COLOR: #0000ff">="ajax/AjaxPlay.Sample,AjaxPlay.ashx"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="Form1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;method</SPAN><SPAN style="COLOR: #0000ff">="post"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;runat</SPAN><SPAN style="COLOR: #0000ff">="server"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG src="http://www.cnblogs.com/Images/dot.gif"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>You can test that everything is working properly by manually navigating to the src paths in your browser (view source and copy and paste the paths). If both paths output some (seemingly) meaningless text, you&#8217;ve done well so far.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If they&#8217;re outputting nothing or ASP.Net errors, something was improperly done.<BR></SPAN><SPAN lang=EN-US>Even if you don&#8217;t know how </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">HttpHandlers</SPAN></SPAN><SPAN lang=EN-US> work, the above should be understandable.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Via the <I style="mso-bidi-font-style: normal">web.config</I>, we&#8217;ve made sure that all requests that go to <st1:place w:st="on"><st1:City w:st="on"><I style="mso-bidi-font-style: normal">ajax</I></st1:City></st1:place><I style="mso-bidi-font-style: normal">/*.ashx</I> are processed by the custom handler.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Obviously, the two script tags will be processed by this custom handler.<BR><BR></SPAN><A name=_Toc104130691><SPAN lang=EN-US><STRONG>Creating the Server-Side Functions</STRONG></SPAN></A> 
<P class=MsoNormal><SPAN lang=EN-US>We&#8217;ll now create a server-side function that&#8217;ll be asynchronously be available from a client-side call.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Since not all return types are currently supported (don&#8217;t worry, upcoming versions will build on what&#8217;s currently there), we&#8217;ll stick with our simple </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> functionality.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In the code behind file, add the following method to your page class:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">VB.Net</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">Ajax.AjaxMethod()</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;_<BR><IMG id=Codehighlighter1_37_229_Open_Image onclick="this.style.display='none'; Codehighlighter1_37_229_Open_Text.style.display='none'; Codehighlighter1_37_229_Closed_Image.style.display='inline'; Codehighlighter1_37_229_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_37_229_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_37_229_Closed_Text.style.display='none'; Codehighlighter1_37_229_Open_Image.style.display='inline'; Codehighlighter1_37_229_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_37_229_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Function&nbsp;ServerSideAdd()</SPAN><SPAN id=Codehighlighter1_37_229_Open_Text><SPAN style="COLOR: #0000ff">Function</SPAN><SPAN style="COLOR: #000000">&nbsp;ServerSideAdd&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">byval</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byval</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Return</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Function</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">C#</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">[Ajax.AjaxMethod()]<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;ServerSideAdd(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber)<BR><IMG id=Codehighlighter1_85_124_Open_Image onclick="this.style.display='none'; Codehighlighter1_85_124_Open_Text.style.display='none'; Codehighlighter1_85_124_Closed_Image.style.display='inline'; Codehighlighter1_85_124_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_85_124_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_85_124_Closed_Text.style.display='none'; Codehighlighter1_85_124_Open_Image.style.display='inline'; Codehighlighter1_85_124_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_85_124_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_85_124_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;firstNumber&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;secondNumber;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>Note that the functions have the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Ajax.AjaxMethod </SPAN></SPAN><SPAN lang=EN-US>attribute set.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The attribute serves to tell that wrapper to create JavaScript proxies for these methods so that they might be called client-side.</SPAN> 
<H2><A name=_Toc104130692><SPAN lang=EN-US style="FONT-SIZE: 12pt">Making our client-side call</SPAN></A></H2>
<P class=MsoNormal><SPAN lang=EN-US>The last step is to call the function using JavaScript. The <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> wrapper took care of creating a JavaScript function called </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Sample.ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> function which takes two parameters.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For the most basic functionality, all we need to do is call the method and pass two numbers:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_2_67_Open_Image onclick="this.style.display='none'; Codehighlighter1_2_67_Open_Text.style.display='none'; Codehighlighter1_2_67_Closed_Image.style.display='inline'; Codehighlighter1_2_67_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_2_67_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2_67_Closed_Text.style.display='none'; Codehighlighter1_2_67_Open_Image.style.display='inline'; Codehighlighter1_2_67_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_2_67_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_2_67_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">@&nbsp;Page&nbsp;Inherits</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">AjaxPlay.Sample</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;Codebehind</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sample.aspx.cs</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;<IMG src="http://www.cnblogs.com/Images/dot.gif">&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="javascript"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;src</SPAN><SPAN style="COLOR: #0000ff">="ajax/common.ashx"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="javascript"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src</SPAN><SPAN style="COLOR: #0000ff">="ajax/AjaxPlay.Sample,AjaxPlay.ashx"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="Form1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;method</SPAN><SPAN style="COLOR: #0000ff">="post"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;runat</SPAN><SPAN style="COLOR: #0000ff">="server"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_351_441_Open_Image onclick="this.style.display='none'; Codehighlighter1_351_441_Open_Text.style.display='none'; Codehighlighter1_351_441_Closed_Image.style.display='inline'; Codehighlighter1_351_441_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_351_441_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_351_441_Closed_Text.style.display='none'; Codehighlighter1_351_441_Open_Image.style.display='inline'; Codehighlighter1_351_441_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="javascript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN id=Codehighlighter1_351_441_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_351_441_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;response&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;Sample.ServerSideAdd(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">100</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">99</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(response.value);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>Of course, we&#8217;ll want to use this powerful capability for more than simply alerting the user.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That&#8217;s why all client-side proxies (such as the JavaScript </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Sample.ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> function), also accept an additional property.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The property is the callback function called in order to process the response:<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Sample.ServerSideAdd(</SPAN><SPAN style="COLOR: #000000">100</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">99</SPAN><SPAN style="COLOR: #000000">,&nbsp;ServerSideAdd_CallBack);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_96_192_Open_Image onclick="this.style.display='none'; Codehighlighter1_96_192_Open_Text.style.display='none'; Codehighlighter1_96_192_Closed_Image.style.display='inline'; Codehighlighter1_96_192_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_96_192_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_96_192_Closed_Text.style.display='none'; Codehighlighter1_96_192_Open_Image.style.display='inline'; Codehighlighter1_96_192_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;ServerSideAdd_CallBack(response)</SPAN><SPAN id=Codehighlighter1_96_192_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_96_192_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_126_166_Open_Image onclick="this.style.display='none'; Codehighlighter1_126_166_Open_Text.style.display='none'; Codehighlighter1_126_166_Closed_Image.style.display='inline'; Codehighlighter1_126_166_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_126_166_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_126_166_Closed_Text.style.display='none'; Codehighlighter1_126_166_Open_Image.style.display='inline'; Codehighlighter1_126_166_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(response.error&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_126_166_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_126_166_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;alert(response.error);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;alert(response.value);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>We can see from the above code that we&#8217;ve specified an extra parameter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd_CallBack </SPAN></SPAN><SPAN lang=EN-US>(also shown above) is the client-side function used to process the response from the server.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>The callback function receives a response object which exposes three key properties:</SPAN> 
<TABLE class=Table style="BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 59.4pt; PADDING-TOP: 0cm" vAlign=top width=79>
<P class=Code-Inline><SPAN lang=EN-US>value</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 383.4pt; PADDING-TOP: 0cm" vAlign=top width=511>
<P class=MsoNormal><SPAN lang=EN-US>The actual return value (be it a string, custom object or dataset) of the server-side function.</SPAN></P></TD></TR>
<TR style="mso-yfti-irow: 1">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 59.4pt; PADDING-TOP: 0cm" vAlign=top width=79>
<P class=Code-Inline><SPAN lang=EN-US>error</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 383.4pt; PADDING-TOP: 0cm" vAlign=top width=511>
<P class=MsoNormal><SPAN lang=EN-US>An error message, if any.</SPAN></P></TD></TR>
<TR style="mso-yfti-irow: 2">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 59.4pt; PADDING-TOP: 0cm" vAlign=top width=79>
<P class=Code-Inline><SPAN lang=EN-US>request</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 383.4pt; PADDING-TOP: 0cm" vAlign=top width=511>
<P class=MsoNormal><SPAN lang=EN-US>The raw response from the xml http request.</SPAN></P></TD></TR>
<TR style="mso-yfti-irow: 3; mso-yfti-lastrow: yes">
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 59.4pt; PADDING-TOP: 0cm" vAlign=top width=79>
<P class=Code-Inline><SPAN lang=EN-US>context</SPAN></P></TD>
<TD style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; WIDTH: 383.4pt; PADDING-TOP: 0cm" vAlign=top width=511>
<P class=MsoNormal><SPAN lang=EN-US>A context object.</SPAN></P></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN lang=EN-US>First we check the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">error</SPAN></SPAN><SPAN lang=EN-US> value to see if any errors occurred.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You can easily play with the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">error</SPAN></SPAN><SPAN lang=EN-US> property by throwing an exception in the server-side function.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Then, in this simplified case, we alert the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">value</SPAN></SPAN><SPAN lang=EN-US>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">request</SPAN></SPAN><SPAN lang=EN-US> property can be used to get additional information (see box bellow).</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid #993300 1.0pt; mso-yfti-tbllook: 480; mso-padding-alt: 10.8pt 5.75pt 10.8pt 5.75pt; mso-border-insideh: 1.0pt solid #993300; mso-border-insidev: 1.0pt solid #993300" cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: #993300 1pt solid; WIDTH: 36.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid" vAlign=top width=48>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 24.75pt; HEIGHT: 24.75pt" type="#_x0000_t75"><v:imagedata o:title="info" src="file:///C:\DOCUME~1\wangaw\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><IMG height=33 hspace=0 src="http://www.cnblogs.com/images/cnblogs_com/ghost1980/clip_image001.jpg" width=33></v:imagedata></v:shape><o:p></o:p></SPAN></P></TD>
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: medium none; WIDTH: 407.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid; mso-border-left-alt: solid #993300 1.0pt" vAlign=top width=543>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt">To learn more about the Xml Http request, check out the following link dump:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><A href="http://www.quirksmode.org/blog/archives/2005/02/xmlhttp_linkdum.html">http://www.quirksmode.org/blog/archives/2005/02/xmlhttp_linkdum.html</A><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN lang=EN-US><SPAN style="FONT-SIZE: 12pt"><A name=_Toc104130693><SPAN lang=EN-US><STRONG><SPAN style="FONT-SIZE: 12pt"></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN style="FONT-SIZE: 12pt"></A><A name=_Toc104130693><SPAN lang=EN-US><STRONG>Dealing with Types</STRONG></SPAN></A><A name=_Toc104130693><BR></A><A name=_Toc104130694><SPAN lang=EN-US><STRONG>Returning complex types</STRONG></SPAN></A><A name=_Toc104130693></A><A name=_Toc104130693></SPAN></SPAN></P>
<P class=MsoNormal></SPAN></STRONG></SPAN></A></SPAN></SPAN><SPAN lang=EN-US>The <st1:place w:st="on"><st1:City w:st="on">Ajax</st1:City></st1:place> wrapper is capable of handling more than just the integer our </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> function returned.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It currently supports </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">integers</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">strings</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">double</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">booleans</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DateTime</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DataSets</SPAN></SPAN><SPAN lang=EN-US> and </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DataTables</SPAN></SPAN><SPAN lang=EN-US>, as well as the primitive types of custom classes and arrays.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>All other types have their </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ToString</SPAN></SPAN><SPAN lang=EN-US> values returned.<BR></SPAN><SPAN lang=EN-US>Returned </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DataSets</SPAN></SPAN><SPAN lang=EN-US> work much like real .Net </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DataSet</SPAN></SPAN><SPAN lang=EN-US>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Given a server side function which returns a </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">DataSet</SPAN></SPAN><SPAN lang=EN-US>, we could display the contents client side via:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">script&nbsp;language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">JavaScript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Asynchronous&nbsp;call&nbsp;to&nbsp;the&nbsp;mythical&nbsp;"GetDataSet"&nbsp;server-side&nbsp;function</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_122_176_Open_Image onclick="this.style.display='none'; Codehighlighter1_122_176_Open_Text.style.display='none'; Codehighlighter1_122_176_Closed_Image.style.display='inline'; Codehighlighter1_122_176_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_122_176_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_122_176_Closed_Text.style.display='none'; Codehighlighter1_122_176_Open_Image.style.display='inline'; Codehighlighter1_122_176_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;getDataSet()</SPAN><SPAN id=Codehighlighter1_122_176_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_122_176_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;AjaxFunctions.GetDataSet(GetDataSet_callback);&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_216_747_Open_Image onclick="this.style.display='none'; Codehighlighter1_216_747_Open_Text.style.display='none'; Codehighlighter1_216_747_Closed_Image.style.display='inline'; Codehighlighter1_216_747_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_216_747_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_216_747_Closed_Text.style.display='none'; Codehighlighter1_216_747_Open_Image.style.display='inline'; Codehighlighter1_216_747_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;GetDataSet_callback(response)</SPAN><SPAN id=Codehighlighter1_216_747_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_216_747_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;ds&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value;<BR><IMG id=Codehighlighter1_306_674_Open_Image onclick="this.style.display='none'; Codehighlighter1_306_674_Open_Text.style.display='none'; Codehighlighter1_306_674_Closed_Image.style.display='inline'; Codehighlighter1_306_674_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_306_674_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_306_674_Closed_Text.style.display='none'; Codehighlighter1_306_674_Open_Image.style.display='inline'; Codehighlighter1_306_674_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(ds&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&amp;&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">typeof</SPAN><SPAN style="COLOR: #000000">(ds)&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">object</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&amp;&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;ds.Tables&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_306_674_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_306_674_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;s&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;Array();<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;table&nbsp;border=1&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG id=Codehighlighter1_414_604_Open_Image onclick="this.style.display='none'; Codehighlighter1_414_604_Open_Text.style.display='none'; Codehighlighter1_414_604_Closed_Image.style.display='inline'; Codehighlighter1_414_604_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_414_604_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_414_604_Closed_Text.style.display='none'; Codehighlighter1_414_604_Open_Image.style.display='inline'; Codehighlighter1_414_604_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;i</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;&nbsp;i</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">ds.Tables[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">].Rows.length;&nbsp;i</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_414_604_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_414_604_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;tr&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;ds.Tables[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">].Rows[i].FirstName&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;ds.Tables[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">].Rows[i].Birthday&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/tr&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;s[s.length]&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/table&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;tableDisplay.innerHTML&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;s.join(</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_681_745_Open_Image onclick="this.style.display='none'; Codehighlighter1_681_745_Open_Text.style.display='none'; Codehighlighter1_681_745_Closed_Image.style.display='inline'; Codehighlighter1_681_745_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_681_745_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_681_745_Closed_Text.style.display='none'; Codehighlighter1_681_745_Open_Image.style.display='inline'; Codehighlighter1_681_745_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN id=Codehighlighter1_681_745_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_681_745_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;alert(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Error.&nbsp;[3001]&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;response.request.responseText);&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;/</SPAN><SPAN style="COLOR: #000000">script</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><st1:City w:st="on"><st1:place w:st="on"><SPAN lang=EN-US>Ajax</SPAN></st1:place></st1:City><SPAN lang=EN-US> can also return custom classes. All that is required is that the class be marked with the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Serializable </SPAN></SPAN><SPAN lang=EN-US>attribute.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Given the following class:<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">[Serializable()]<BR><IMG id=Codehighlighter1_34_606_Open_Image onclick="this.style.display='none'; Codehighlighter1_34_606_Open_Text.style.display='none'; Codehighlighter1_34_606_Closed_Image.style.display='inline'; Codehighlighter1_34_606_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_34_606_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_34_606_Closed_Text.style.display='none'; Codehighlighter1_34_606_Open_Image.style.display='inline'; Codehighlighter1_34_606_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;User</SPAN><SPAN id=Codehighlighter1_34_606_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_34_606_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;_userId;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;_firstName;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;_lastName;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_132_161_Open_Image onclick="this.style.display='none'; Codehighlighter1_132_161_Open_Text.style.display='none'; Codehighlighter1_132_161_Closed_Image.style.display='inline'; Codehighlighter1_132_161_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_132_161_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_132_161_Closed_Text.style.display='none'; Codehighlighter1_132_161_Open_Image.style.display='inline'; Codehighlighter1_132_161_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;userId</SPAN><SPAN id=Codehighlighter1_132_161_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_132_161_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_140_158_Open_Image onclick="this.style.display='none'; Codehighlighter1_140_158_Open_Text.style.display='none'; Codehighlighter1_140_158_Closed_Image.style.display='inline'; Codehighlighter1_140_158_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_140_158_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_140_158_Closed_Text.style.display='none'; Codehighlighter1_140_158_Open_Image.style.display='inline'; Codehighlighter1_140_158_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_140_158_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_140_158_Open_Text><SPAN style="COLOR: #000000">{&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_userId;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_187_219_Open_Image onclick="this.style.display='none'; Codehighlighter1_187_219_Open_Text.style.display='none'; Codehighlighter1_187_219_Closed_Image.style.display='inline'; Codehighlighter1_187_219_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_187_219_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_187_219_Closed_Text.style.display='none'; Codehighlighter1_187_219_Open_Image.style.display='inline'; Codehighlighter1_187_219_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;FirstName</SPAN><SPAN id=Codehighlighter1_187_219_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_187_219_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_195_216_Open_Image onclick="this.style.display='none'; Codehighlighter1_195_216_Open_Text.style.display='none'; Codehighlighter1_195_216_Closed_Image.style.display='inline'; Codehighlighter1_195_216_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_195_216_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_195_216_Closed_Text.style.display='none'; Codehighlighter1_195_216_Open_Image.style.display='inline'; Codehighlighter1_195_216_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_195_216_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_195_216_Open_Text><SPAN style="COLOR: #000000">{&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_firstName;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_244_275_Open_Image onclick="this.style.display='none'; Codehighlighter1_244_275_Open_Text.style.display='none'; Codehighlighter1_244_275_Closed_Image.style.display='inline'; Codehighlighter1_244_275_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_244_275_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_244_275_Closed_Text.style.display='none'; Codehighlighter1_244_275_Open_Image.style.display='inline'; Codehighlighter1_244_275_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;LastName</SPAN><SPAN id=Codehighlighter1_244_275_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_244_275_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_252_272_Open_Image onclick="this.style.display='none'; Codehighlighter1_252_272_Open_Text.style.display='none'; Codehighlighter1_252_272_Closed_Image.style.display='inline'; Codehighlighter1_252_272_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_252_272_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_252_272_Closed_Text.style.display='none'; Codehighlighter1_252_272_Open_Image.style.display='inline'; Codehighlighter1_252_272_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_252_272_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_252_272_Open_Text><SPAN style="COLOR: #000000">{&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_lastName;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_340_431_Open_Image onclick="this.style.display='none'; Codehighlighter1_340_431_Open_Text.style.display='none'; Codehighlighter1_340_431_Closed_Image.style.display='inline'; Codehighlighter1_340_431_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_340_431_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_340_431_Closed_Text.style.display='none'; Codehighlighter1_340_431_Open_Image.style.display='inline'; Codehighlighter1_340_431_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;User(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;_userId,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;_firstName,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;_lastName)</SPAN><SPAN id=Codehighlighter1_340_431_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_340_431_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">._userId&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;_userId;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">._firstName&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;_firstName;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">._lastName&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;_lastName;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_447_448_Open_Image onclick="this.style.display='none'; Codehighlighter1_447_448_Open_Text.style.display='none'; Codehighlighter1_447_448_Closed_Image.style.display='inline'; Codehighlighter1_447_448_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_447_448_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_447_448_Closed_Text.style.display='none'; Codehighlighter1_447_448_Open_Image.style.display='inline'; Codehighlighter1_447_448_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;User()</SPAN><SPAN id=Codehighlighter1_447_448_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_447_448_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;[AjaxMethod()]<BR><IMG id=Codehighlighter1_506_604_Open_Image onclick="this.style.display='none'; Codehighlighter1_506_604_Open_Text.style.display='none'; Codehighlighter1_506_604_Closed_Image.style.display='inline'; Codehighlighter1_506_604_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_506_604_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_506_604_Closed_Text.style.display='none'; Codehighlighter1_506_604_Open_Image.style.display='inline'; Codehighlighter1_506_604_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;User&nbsp;GetUser(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;userId)</SPAN><SPAN id=Codehighlighter1_506_604_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_506_604_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Replace&nbsp;this&nbsp;with&nbsp;a&nbsp;DB&nbsp;hit&nbsp;or&nbsp;something&nbsp;:)</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;User(userId,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Michael</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Schwarz</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>We would register the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">GetUser</SPAN></SPAN><SPAN lang=EN-US> proxy via a call to the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">RegisterTypeForAjax</SPAN></SPAN><SPAN lang=EN-US>:<BR></SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'"><o:p></o:p></SPAN></SPAN>
<P class=MsoNormal><SPAN lang=EN-US><o:p></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_50_96_Open_Image onclick="this.style.display='none'; Codehighlighter1_50_96_Open_Text.style.display='none'; Codehighlighter1_50_96_Closed_Image.style.display='inline'; Codehighlighter1_50_96_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_50_96_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_50_96_Closed_Text.style.display='none'; Codehighlighter1_50_96_Open_Image.style.display='inline'; Codehighlighter1_50_96_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Page_Load(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;sender,&nbsp;EventArgs&nbsp;e)</SPAN><SPAN id=Codehighlighter1_50_96_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_50_96_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;Utility.RegisterTypeForAjax(</SPAN><SPAN style="COLOR: #0000ff">typeof</SPAN><SPAN style="COLOR: #000000">(User));<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN></DIV>
<P class=MsoNormal></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">Allowing us to asynchronously call the GetUser in client-side code with code such as:</SPAN>&nbsp;<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">script&nbsp;language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">javascript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_55_90_Open_Image onclick="this.style.display='none'; Codehighlighter1_55_90_Open_Text.style.display='none'; Codehighlighter1_55_90_Closed_Image.style.display='inline'; Codehighlighter1_55_90_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_55_90_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_55_90_Closed_Text.style.display='none'; Codehighlighter1_55_90_Open_Image.style.display='inline'; Codehighlighter1_55_90_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;getUser(userId)</SPAN><SPAN id=Codehighlighter1_55_90_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_55_90_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;User.GetUser(GetUser_callback);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_127_306_Open_Image onclick="this.style.display='none'; Codehighlighter1_127_306_Open_Text.style.display='none'; Codehighlighter1_127_306_Closed_Image.style.display='inline'; Codehighlighter1_127_306_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_127_306_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_127_306_Closed_Text.style.display='none'; Codehighlighter1_127_306_Open_Image.style.display='inline'; Codehighlighter1_127_306_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;GetUser_callback(response)</SPAN><SPAN id=Codehighlighter1_127_306_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_127_306_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_177_304_Open_Image onclick="this.style.display='none'; Codehighlighter1_177_304_Open_Text.style.display='none'; Codehighlighter1_177_304_Closed_Image.style.display='inline'; Codehighlighter1_177_304_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_177_304_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_177_304_Closed_Text.style.display='none'; Codehighlighter1_177_304_Open_Image.style.display='inline'; Codehighlighter1_177_304_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(response&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&amp;&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_177_304_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_177_304_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;user&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value;<BR><IMG id=Codehighlighter1_239_301_Open_Image onclick="this.style.display='none'; Codehighlighter1_239_301_Open_Text.style.display='none'; Codehighlighter1_239_301_Closed_Image.style.display='inline'; Codehighlighter1_239_301_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_239_301_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_239_301_Closed_Text.style.display='none'; Codehighlighter1_239_301_Open_Image.style.display='inline'; Codehighlighter1_239_301_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">typeof</SPAN><SPAN style="COLOR: #000000">(user)&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">object</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_239_301_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_239_301_Open_Text><SPAN style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;alert(user.FirstName&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;user.LastName);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>getUser(</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;/</SPAN><SPAN style="COLOR: #000000">script</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV><SPAN lang=EN-US>The value returned in the response is actually an object which exposes the same properties as a server-side object (</SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">FirstName</SPAN></SPAN><SPAN lang=EN-US>, </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">LastName</SPAN></SPAN><SPAN lang=EN-US> and </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">UserId</SPAN></SPAN><SPAN lang=EN-US>).<BR><BR></SPAN><A name=_Toc104130695><SPAN lang=EN-US><STRONG style="FONT-SIZE: 12pt">Custom Converters</STRONG></SPAN></A> 
<P class=MsoNormal><SPAN lang=EN-US>As we&#8217;ve seen, the <st1:place w:st="on"><st1:City w:st="on">Ajax</st1:City></st1:place> .Net wrapper is able to deal with many different .Net types.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>However, aside from a handful of .Net classes and the built-in types, the wrapper simply calls </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ToString()</SPAN></SPAN><SPAN lang=EN-US> on anything it can&#8217;t properly return.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To get around this, the <st1:place w:st="on"><st1:City w:st="on">Ajax</st1:City></st1:place> .Net wrapper allows developers to create object converters which can be used to smoothly communicate complex objects between the server and the client.<SPAN style="mso-spacerun: yes">&nbsp; <BR></SPAN></SPAN><SPAN lang=EN-US>This guide will be updated with additional information on custom converters shortly (sorry).</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN style="FONT-SIZE: 12pt"><A name=_Toc104130696><SPAN lang=EN-US><STRONG>Miscellaneous</STRONG></SPAN></A><BR><A name=_Toc104130697><SPAN lang=EN-US><STRONG>Registering functions in another class<BR></STRONG></SPAN></A></SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"><BR>In the above example, our server-side functions resided within the code behind of the executing page.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>However, there&#8217;s no reason why these functions can&#8217;t be in a separate class file.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Remember, the way the wrapper works is to find all methods within the specified class that have the </SPAN><st1:place w:st="on"><st1:City w:st="on"><SPAN class=Code-InlineChar><SPAN lang=EN-US style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'">Ajax</SPAN></SPAN></st1:City></st1:place><SPAN class=Code-InlineChar><SPAN lang=EN-US style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'">.AjaxMethod</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">. The class in question is specified via the second script tag.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Using </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'">Ajax.Utility.RegisterTypeForAjax</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"> we can specify any class we want.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, it would be reasonable to keep our server-side functions in a separate class:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_7_185_Open_Image onclick="this.style.display='none'; Codehighlighter1_7_185_Open_Text.style.display='none'; Codehighlighter1_7_185_Closed_Image.style.display='inline'; Codehighlighter1_7_185_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_7_185_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_7_185_Closed_Text.style.display='none'; Codehighlighter1_7_185_Open_Image.style.display='inline'; Codehighlighter1_7_185_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">Public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_7_185_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Class&nbsp;AjaxFunctions</SPAN><SPAN id=Codehighlighter1_7_185_Open_Text><SPAN style="COLOR: #0000ff">Class</SPAN><SPAN style="COLOR: #000000">&nbsp;AjaxFunctions<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">Ajax.AjaxMethod()</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;_<BR><IMG id=Codehighlighter1_58_175_Open_Image onclick="this.style.display='none'; Codehighlighter1_58_175_Open_Text.style.display='none'; Codehighlighter1_58_175_Closed_Image.style.display='inline'; Codehighlighter1_58_175_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_58_175_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_58_175_Closed_Text.style.display='none'; Codehighlighter1_58_175_Open_Image.style.display='inline'; Codehighlighter1_58_175_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_58_175_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Function&nbsp;Validate()</SPAN><SPAN id=Codehighlighter1_58_175_Open_Text><SPAN style="COLOR: #0000ff">Function</SPAN><SPAN style="COLOR: #000000">&nbsp;Validate(username&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">String</SPAN><SPAN style="COLOR: #000000">,&nbsp;password&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">String</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Boolean</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">do&nbsp;something</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">Return&nbsp;something</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Function</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Class</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal><SPAN lang=EN-US>We could have the <st1:City w:st="on"><st1:place w:st="on">Ajax</st1:place></st1:City> wrapper create proxies for this class by specifying this class&#8217;s type instead of the pages:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">Vb.Net</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_16_154_Open_Image onclick="this.style.display='none'; Codehighlighter1_16_154_Open_Text.style.display='none'; Codehighlighter1_16_154_Closed_Image.style.display='inline'; Codehighlighter1_16_154_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_16_154_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_16_154_Closed_Text.style.display='none'; Codehighlighter1_16_154_Open_Image.style.display='inline'; Codehighlighter1_16_154_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_16_154_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Sub&nbsp;Page_Load()</SPAN><SPAN id=Codehighlighter1_16_154_Open_Text><SPAN style="COLOR: #0000ff">Sub</SPAN><SPAN style="COLOR: #000000">&nbsp;Page_Load(sender&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Object</SPAN><SPAN style="COLOR: #000000">,&nbsp;e&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;EventArgs)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Handles</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">MyBase</SPAN><SPAN style="COLOR: #000000">.Load<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;Ajax.Utility.RegisterTypeForAjax(</SPAN><SPAN style="COLOR: #0000ff">GetType</SPAN><SPAN style="COLOR: #000000">(AjaxFunctions))<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Sub</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal></SPAN>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">C#</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_55_122_Open_Image onclick="this.style.display='none'; Codehighlighter1_55_122_Open_Text.style.display='none'; Codehighlighter1_55_122_Closed_Image.style.display='inline'; Codehighlighter1_55_122_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_55_122_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_55_122_Closed_Text.style.display='none'; Codehighlighter1_55_122_Open_Image.style.display='inline'; Codehighlighter1_55_122_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Page_Load(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;sender,&nbsp;EventArgs&nbsp;e)</SPAN><SPAN id=Codehighlighter1_55_122_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_55_122_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;Ajax.Utility.RegisterTypeForAjax(</SPAN><SPAN style="COLOR: #0000ff">typeof</SPAN><SPAN style="COLOR: #000000">(AjaxFunctions));<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal><SPAN lang=EN-US>Remember, the client-side proxy takes the name of </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">&lt;ClassName&gt;.&lt;ServerSideFunctionName&gt;</SPAN></SPAN><SPAN lang=EN-US>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Therefore, if our </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> function was located in the fictional </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxFunctions</SPAN></SPAN><SPAN lang=EN-US> class above, our client-side call would be: </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxFunctions.ServerSideAdd(1,2)</SPAN></SPAN></P>
<H3><A name=_Toc104130698><SPAN lang=EN-US style="FONT-SIZE: 12pt">How the proxy really works</SPAN></A></H3>
<P class=MsoNormal><SPAN lang=EN-US>The second script tag generated by the <st1:place w:st="on"><st1:City w:st="on">Ajax</st1:City></st1:place> utility (or manually inserted by you) passes the namespace, class name and assembly of the page.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Armed with this information, the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Ajax.PageHandlerFactory</SPAN></SPAN><SPAN lang=EN-US> is able to use reflection and get the details about any functions which have a certain attribute.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Obviously, the handler looks for functions with the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxMethod</SPAN></SPAN><SPAN lang=EN-US> attribute, gets their signature (return type, name, and parameters) and is thus able to create the necessary client-side proxy.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Specifically, the wrapper creates a JavaScript object named the same name as your class which exposes the proxy.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In other words, given a server-side class </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxFunctions</SPAN></SPAN><SPAN lang=EN-US> with an <st1:place w:st="on"><st1:City w:st="on">Ajax</st1:City></st1:place> method </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US>, we should expect a JavaScript object named </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">AjaxFunction</SPAN></SPAN><SPAN lang=EN-US> which exposes a </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ServerSideAdd</SPAN></SPAN><SPAN lang=EN-US> function.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You can see this in action by pointing your browser to the path of the second script tag.</SPAN></P>
<H3><A name=_Toc104130699><SPAN lang=EN-US style="FONT-SIZE: 12pt">Returning Unicode characters</SPAN></A></H3>
<P class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><SPAN lang=EN-US>Ajax</SPAN></st1:place></st1:City><SPAN lang=EN-US> .Net wrapper is able to return Unicode characters from the server to the client.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To do so, values must be html encoded on the server before being returned.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example:<BR></SPAN></P>
<P class=MsoNormal>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">[Ajax.AjaxMethod]<BR><IMG id=Codehighlighter1_80_264_Open_Image onclick="this.style.display='none'; Codehighlighter1_80_264_Open_Text.style.display='none'; Codehighlighter1_80_264_Closed_Image.style.display='inline'; Codehighlighter1_80_264_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_80_264_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_80_264_Closed_Text.style.display='none'; Codehighlighter1_80_264_Open_Image.style.display='inline'; Codehighlighter1_80_264_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;Test1(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;name,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;email,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;comment)</SPAN><SPAN id=Codehighlighter1_80_264_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_80_264_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;html&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Hello&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;name&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;br&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;comment&nbsp;&lt;b&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;System.Web.HttpUtility.HtmlEncode(comment);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/b&gt;.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;html;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal><A name=_Toc104130700><SPAN lang=EN-US style="FONT-SIZE: 12pt">SessionState</SPAN></A></P>
<P class=MsoNormal><SPAN lang=EN-US>It&#8217;s likely that you&#8217;ll need to access session information in your server side function.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To do so, you must simply tell <st1:City w:st="on"><st1:place w:st="on">Ajax</st1:place></st1:City> to enable such functionality via a parameter passed to the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Ajax.AjaxMethod </SPAN></SPAN><SPAN lang=EN-US>attribute.<SPAN style="mso-spacerun: yes">&nbsp; <BR></SPAN></SPAN><SPAN lang=EN-US>While looking at the session capabilities of the wrapper, let&#8217;s look at a couple other features.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In this example, we have a document management system which puts a lock on a document while a user is editing it.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Other users can request to be notified when the document because available.<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>Without <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City>, we&#8217;d need to wait until the user posted back in order to check if his or her queued documents were available.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is obviously not ideal.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Using <st1:City w:st="on"><st1:place w:st="on">Ajax</st1:place></st1:City> with session state support, this is quite easy.<BR></SPAN><SPAN lang=EN-US>First we&#8217;ll write our server side function, the goal of which is to loop through the documentIds the user wishes to edit (stored in a session) and return all released documents.<BR></SPAN></P>
<P class=MsoNormal>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">'</SPAN><SPAN style="COLOR: #008000">Vb.Net</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">Ajax.AjaxMethod(HttpSessionStateRequirement.Read)</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;_<BR><IMG id=Codehighlighter1_69_612_Open_Image onclick="this.style.display='none'; Codehighlighter1_69_612_Open_Text.style.display='none'; Codehighlighter1_69_612_Closed_Image.style.display='inline'; Codehighlighter1_69_612_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_69_612_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_69_612_Closed_Text.style.display='none'; Codehighlighter1_69_612_Open_Image.style.display='inline'; Codehighlighter1_69_612_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_69_612_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Function&nbsp;DocumentReleased()</SPAN><SPAN id=Codehighlighter1_69_612_Open_Text><SPAN style="COLOR: #0000ff">Function</SPAN><SPAN style="COLOR: #000000">&nbsp;DocumentReleased()&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;ArrayList<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">If</SPAN><SPAN style="COLOR: #000000">&nbsp;HttpContext.Current.Session(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">DocumentsWaiting</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Is</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Nothing</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Then</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Nothing</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">End</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">If</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Dim</SPAN><SPAN style="COLOR: #000000">&nbsp;readyDocuments&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">New</SPAN><SPAN style="COLOR: #000000">&nbsp;ArrayList<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Dim</SPAN><SPAN style="COLOR: #000000">&nbsp;documents()&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">CType</SPAN><SPAN style="COLOR: #000000">(HttpContext.Current.Session(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">DocumentsWaiting</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">),&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000">())<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">For</SPAN><SPAN style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Integer</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">To</SPAN><SPAN style="COLOR: #000000">&nbsp;documents.Length&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Dim</SPAN><SPAN style="COLOR: #000000">&nbsp;document&nbsp;</SPAN><SPAN style="COLOR: #0000ff">As</SPAN><SPAN style="COLOR: #000000">&nbsp;Document&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;document.GetDocumentById(documents(i))<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">If</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Not</SPAN><SPAN style="COLOR: #000000">&nbsp;document&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Is</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Nothing</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">AndAlso</SPAN><SPAN style="COLOR: #000000">&nbsp;document.Status&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;DocumentStatus.Ready&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Then</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;readyDocuments.Add(document)<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">End</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">If</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Next</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Return</SPAN><SPAN style="COLOR: #000000">&nbsp;readyDocuments<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">End&nbsp;Function</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">C#</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">[Ajax.AjaxMethod(HttpSessionStateRequirement.Read)]<BR><IMG id=Codehighlighter1_92_544_Open_Image onclick="this.style.display='none'; Codehighlighter1_92_544_Open_Text.style.display='none'; Codehighlighter1_92_544_Closed_Image.style.display='inline'; Codehighlighter1_92_544_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_92_544_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_92_544_Closed_Text.style.display='none'; Codehighlighter1_92_544_Open_Image.style.display='inline'; Codehighlighter1_92_544_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;ArrayList&nbsp;DocumentReleased()</SPAN><SPAN id=Codehighlighter1_92_544_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_92_544_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_155_173_Open_Image onclick="this.style.display='none'; Codehighlighter1_155_173_Open_Text.style.display='none'; Codehighlighter1_155_173_Closed_Image.style.display='inline'; Codehighlighter1_155_173_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_155_173_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_155_173_Closed_Text.style.display='none'; Codehighlighter1_155_173_Open_Image.style.display='inline'; Codehighlighter1_155_173_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(HttpContext.Current.Session[</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">DocumentsWaiting</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">]&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_155_173_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_155_173_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;ArrayList&nbsp;readyDocuments&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;ArrayList();<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">[]&nbsp;documents&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">[])HttpContext.Current.Session[</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">DocumentsWaiting</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">];<BR><IMG id=Codehighlighter1_338_517_Open_Image onclick="this.style.display='none'; Codehighlighter1_338_517_Open_Text.style.display='none'; Codehighlighter1_338_517_Closed_Image.style.display='inline'; Codehighlighter1_338_517_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_338_517_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_338_517_Closed_Text.style.display='none'; Codehighlighter1_338_517_Open_Image.style.display='inline'; Codehighlighter1_338_517_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">&nbsp;documents.Length;&nbsp;</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">i)</SPAN><SPAN id=Codehighlighter1_338_517_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_338_517_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Document&nbsp;document&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Document.GetDocumentById(documents[i]);<BR><IMG id=Codehighlighter1_468_506_Open_Image onclick="this.style.display='none'; Codehighlighter1_468_506_Open_Text.style.display='none'; Codehighlighter1_468_506_Closed_Image.style.display='inline'; Codehighlighter1_468_506_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_468_506_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_468_506_Closed_Text.style.display='none'; Codehighlighter1_468_506_Open_Image.style.display='inline'; Codehighlighter1_468_506_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(document&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&amp;&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;document.Status&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;DocumentStatus.Ready)</SPAN><SPAN id=Codehighlighter1_468_506_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_468_506_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;readyDocuments.Add(document);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;readyDocuments;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>}<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal><SPAN lang=EN-US>Notice that we specify the </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">HttpSessionStateRequirement.Read</SPAN></SPAN><SPAN lang=EN-US> value (alternatives being </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">Write</SPAN></SPAN><SPAN lang=EN-US> and </SPAN><SPAN class=Code-InlineChar><SPAN lang=EN-US style="mso-bidi-font-family: 'Times New Roman'">ReadWrite</SPAN></SPAN><SPAN lang=EN-US>).<BR></SPAN><SPAN lang=EN-US>Now we write our JavaScript to take advantage of this method:<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">script&nbsp;language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">javascript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_73_582_Open_Image onclick="this.style.display='none'; Codehighlighter1_73_582_Open_Text.style.display='none'; Codehighlighter1_73_582_Closed_Image.style.display='inline'; Codehighlighter1_73_582_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_73_582_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_73_582_Closed_Text.style.display='none'; Codehighlighter1_73_582_Open_Image.style.display='inline'; Codehighlighter1_73_582_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;DocumentsReady_CallBack(response)</SPAN><SPAN id=Codehighlighter1_73_582_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_73_582_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_103_141_Open_Image onclick="this.style.display='none'; Codehighlighter1_103_141_Open_Text.style.display='none'; Codehighlighter1_103_141_Closed_Image.style.display='inline'; Codehighlighter1_103_141_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_103_141_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_103_141_Closed_Text.style.display='none'; Codehighlighter1_103_141_Open_Image.style.display='inline'; Codehighlighter1_103_141_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(response.error&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_103_141_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_103_141_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;alert(response.error);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_200_510_Open_Image onclick="this.style.display='none'; Codehighlighter1_200_510_Open_Text.style.display='none'; Codehighlighter1_200_510_Closed_Image.style.display='inline'; Codehighlighter1_200_510_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_200_510_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_200_510_Closed_Text.style.display='none'; Codehighlighter1_200_510_Open_Image.style.display='inline'; Codehighlighter1_200_510_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(response.value&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">&amp;&amp;</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value.length&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_200_510_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_200_510_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;div&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;document.getElementById(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">status</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;div.innerHTML&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">The&nbsp;following&nbsp;documents&nbsp;are&nbsp;ready!&lt;br&nbsp;/&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG id=Codehighlighter1_360_500_Open_Image onclick="this.style.display='none'; Codehighlighter1_360_500_Open_Text.style.display='none'; Codehighlighter1_360_500_Closed_Image.style.display='inline'; Codehighlighter1_360_500_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_360_500_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_360_500_Closed_Text.style.display='none'; Codehighlighter1_360_500_Open_Image.style.display='inline'; Codehighlighter1_360_500_Open_Text.style.display='inline';" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;(</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value.length;&nbsp;</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">i)</SPAN><SPAN id=Codehighlighter1_360_500_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/Images/dot.gif"></SPAN><SPAN id=Codehighlighter1_360_500_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;div.innerHTML&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;a&nbsp;href=\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">edit.aspx</SPAN><SPAN style="COLOR: #000000">?</SPAN><SPAN style="COLOR: #000000">documentId</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;+&nbsp;response.value[i].DocumentId&nbsp;+&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;response.value[i].Name&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/a&gt;&lt;br&nbsp;/&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;setTimeout('page.DocumentReleased(DocumentsReady_CallBack)',&nbsp;</SPAN><SPAN style="COLOR: #000000">10000</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;/</SPAN><SPAN style="COLOR: #000000">script</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;</SPAN><SPAN style="COLOR: #000000">body&nbsp;onload</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">setTimeout('Document.DocumentReleased(DocumentsReady_CallBack)',&nbsp;10000);</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal></SPAN><SPAN lang=EN-US>Our server side function is called once on page load and subsequently every 10 seconds.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The call back function checks the response to see if any values were returned, and if so displays the newly available documents to the user in a div tag.<BR><BR></SPAN><A name=_Toc104130701><SPAN lang=EN-US><STRONG>Conclusion</STRONG></SPAN></A></P>
<P class=MsoNormal><st1:City w:st="on"><st1:place w:st="on"><SPAN lang=EN-US>AJAX</SPAN></st1:place></st1:City><SPAN lang=EN-US> technology has already lead to sleek and rich web interfaces, previously reserved for desktop development.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The <st1:City w:st="on"><st1:place w:st="on">Ajax</st1:place></st1:City> .Net wrapper allows you to easily take advantage of this new power.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Note that both the <st1:City w:st="on"><st1:place w:st="on">Ajax</st1:place></st1:City> .Net wrapper and the documentation are under development.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN></P>
<P class=MsoNormal>
<TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid #993300 1.0pt; mso-yfti-tbllook: 480; mso-padding-alt: 10.8pt 5.75pt 10.8pt 5.75pt; mso-border-insideh: 1.0pt solid #993300; mso-border-insidev: 1.0pt solid #993300" cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: #993300 1pt solid; WIDTH: 36.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid" vAlign=top width=48>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype>&nbsp;<v:shape id=_x0000_i1025 style="WIDTH: 24.75pt; HEIGHT: 24.75pt" type="#_x0000_t75"><v:imagedata o:title="info" src="file:///C:\DOCUME~1\wangaw\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><IMG height=33 hspace=0 src="http://www.cnblogs.com/images/cnblogs_com/ghost1980/clip_image001.jpg" width=33></v:imagedata></v:shape><o:p></o:p></SPAN></P></TD>
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: medium none; WIDTH: 407.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid; mso-border-left-alt: solid #993300 1.0pt" vAlign=top width=543>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt">Keep a close eye on the <st1:City w:st="on"><st1:place w:st="on">AJAX</st1:place></st1:City> .Net wrapper website:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><A href="http://ajax.schwarz-interactive.de/">http://ajax.schwarz-interactive.de/</A><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE><BR>
<TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN-LEFT: 6.75pt; BORDER-LEFT: medium none; MARGIN-RIGHT: 6.75pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid #993300 1.0pt; mso-yfti-tbllook: 480; mso-padding-alt: 10.8pt 5.75pt 10.8pt 5.75pt; mso-border-insideh: 1.0pt solid #993300; mso-border-insidev: 1.0pt solid #993300; mso-table-lspace: 9.0pt; mso-table-rspace: 9.0pt; mso-table-anchor-vertical: paragraph; mso-table-anchor-horizontal: margin; mso-table-left: left; mso-table-top: 14.7pt" cellSpacing=0 cellPadding=0 align=left border=1>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: #993300 1pt solid; WIDTH: 36.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid" vAlign=top width=48>
<P class=MsoNormal style="mso-element: frame; mso-element-frame-hspace: 9.0pt; mso-element-wrap: around; mso-element-anchor-vertical: paragraph; mso-element-anchor-horizontal: margin; mso-element-top: 14.7pt; mso-height-rule: exactly"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><v:shape id=_x0000_i1026 style="WIDTH: 24.75pt; HEIGHT: 24.75pt" type="#_x0000_t75"><v:imagedata o:title="info" src="file:///C:\DOCUME~1\wangaw\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><IMG height=33 hspace=0 src="http://www.cnblogs.com/images/cnblogs_com/ghost1980/clip_image001.jpg" width=33></v:imagedata></v:shape><o:p></o:p></SPAN></P></TD>
<TD style="BORDER-RIGHT: #993300 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: #993300 1pt solid; PADDING-LEFT: 5.75pt; BACKGROUND: #f3f3f3; PADDING-BOTTOM: 10.8pt; BORDER-LEFT: medium none; WIDTH: 407.25pt; PADDING-TOP: 10.8pt; BORDER-BOTTOM: #993300 1pt solid; mso-border-left-alt: solid #993300 1.0pt" vAlign=top width=543>
<P class=MsoNormal style="mso-element: frame; mso-element-frame-hspace: 9.0pt; mso-element-wrap: around; mso-element-anchor-vertical: paragraph; mso-element-anchor-horizontal: margin; mso-element-top: 14.7pt; mso-height-rule: exactly"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt">For a good hands-on sample, check out the following demo application:<o:p></o:p></SPAN></P>
<P class=MsoNormal style="mso-element: frame; mso-element-frame-hspace: 9.0pt; mso-element-wrap: around; mso-element-anchor-vertical: paragraph; mso-element-anchor-horizontal: margin; mso-element-top: 14.7pt; mso-height-rule: exactly"><SPAN lang=EN-US style="COLOR: #993300; mso-bidi-font-size: 10.0pt"><A href="http://ajax.schwarz-interactive.de/download/ajaxsample.zip">http://ajax.schwarz-interactive.de/download/ajaxsample.zip</A></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #993300; mso-bidi-font-size: 12.0pt"><o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
<P class=MsoNormal><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal><BR><BR><BR></SPAN></o:p></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>&nbsp;</P><img src="http://www.cnblogs.com/ghost1980/aggbug/265659.html?type=1" width="1" height="1" alt=""/><p>评论: 10　<a href="http://www.cnblogs.com/ghost1980/archive/2005/10/31/265659.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/ghost1980/archive/2005/10/31/265659.html#commentform" target="_blank">发表评论</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/56793/" target="_blank">知名扩展 Firebug 的简化版登陆 Chrome</a><span style="color:gray">(2010-02-09 22:59)</span><br/>· <a href="http://news.cnblogs.com/n/56792/" target="_blank">Google 悄悄地启用 1e100.net，打枪地不要</a><span style="color:gray">(2010-02-09 22:57)</span><br/>· <a href="http://news.cnblogs.com/n/56791/" target="_blank">从 Google 代码库找到的好东西</a><span style="color:gray">(2010-02-09 22:46)</span><br/>· <a href="http://news.cnblogs.com/n/56789/" target="_blank">苹果在线商店临时关闭 或将推新Macbook</a><span style="color:gray">(2010-02-09 22:39)</span><br/>· <a href="http://news.cnblogs.com/n/56788/" target="_blank">豆瓣网推出豆瓣电台iPhone客户端</a><span style="color:gray">(2010-02-09 21:51)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/56782/" target="_blank">2010年2月编程语言排行榜</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item></channel></rss>