﻿<?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>IT博客-H_J_H-文章分类-AJAX系列</title><link>http://www.cnitblog.com/Johncools/category/1948.html</link><description>------专用杂物房</description><language>zh-cn</language><lastBuildDate>Tue, 11 Oct 2011 09:48:02 GMT</lastBuildDate><pubDate>Tue, 11 Oct 2011 09:48:02 GMT</pubDate><ttl>60</ttl><item><title>ajax急速狂飙：开发99收藏夹体验（二）鼠标拖动</title><link>http://www.cnitblog.com/Johncools/articles/7531.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Mon, 13 Mar 2006 05:30:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/7531.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/7531.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/7531.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/7531.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/7531.html</trackback:ping><description><![CDATA[<FONT size=1>这个问题我一定要提个人：梅花雪！！！！！<BR>有句话说“世上无难事，只要有心人”，<BR>我想说的是：“js无难事，只要梅花来”。<BR>要想实现ie收藏夹一样的功能，那么就要和ie收藏夹一样能够让你随便拖动，而且不需要刷新<BR>，在某些站我看到用户如果一整理收藏夹，那问题就来了，你要半天的等待啊！！<BR>所以我必须要实现在页面上的a标签的拖动，首先我的代码在ie下测试是完全正常的，但是到了<BR>firefox下你拖他理都不理你啊，一直找不出什么原因，求教于梅花老大，很简单的就帮你搞定了，<BR>晕死，一看，原来是我没有正确理解跨浏览器的关于位置的js代码啊！！<BR>晕死，但是实际一做，问题又来拉，在firefox下一拖，还是不动啊！他就是这样的顽固，每办法，<BR>我只好尝试着把要拖动的标签改成div 啊span啊，td 啊。。。。哦，my god!都正常啊！<BR>又改成a，又不可以，又改，这样改了很久，有一次我忘记写a标签的href了，天啊，一拖，竟然拖动<BR>拉！！事情就是这样的古怪啊！！呵呵，看起来懒有时候也是好事啊，所以我的a标签都没有了href<BR>属性了。还有个问题啊，就是保存用户的cookies，我搞了大约一个月，在客户端一直不能够保存用户<BR>的cookies信息太久，关浏览器就没了，后来求教于N位高人，写了无数的正确的代码，都不可以，后来我把web.config里面的&lt;membership defaultProvider="PlProvider" userIsOnlineTimeWindow="30"&gt;这里改成30，原来是15，也就是改成和cookies的timeout时间一样，怪事，竟然完全好了，天啊，一些小问题<BR>怎么经常折磨我这样久啊？<BR>下面是鼠标拖动的代码：里面有个函数我没有复制上来，拖动的时候还是在ie下效果好，因为他能够<BR>设置单个对象的事件捕捉，而firefox不可以。<BR></FONT>
<P><FONT face="Times New Roman" color=#000000 size=1>var beginMoving=false;<BR>var ff=window.navigator.appName=="Netscape"?true:false;<BR>var ie4=document.all?true:false;<BR>var dragClickX, dragClickY;<BR>var beginOpen=true;<BR>var sourceObj=null;<BR>var objectObj=null;<BR>var sourceObjId;<BR>function MouseDownToMove(obj,e)<BR>{<BR>&nbsp;&nbsp; sourceObj=null;<BR>&nbsp;&nbsp; objectObj=null;<BR>&nbsp;&nbsp; beginOpen=true;<BR>&nbsp;&nbsp; e=e||window.event;<BR>&nbsp;&nbsp; beginMoving=true;<BR>&nbsp;&nbsp; sourceObj=obj;<BR>&nbsp;&nbsp; sourceObj.style.zIndex=1;<BR>&nbsp;&nbsp; dragClickY = e.clientY;<BR>&nbsp;&nbsp; dragClickX = e.clientX;<BR>&nbsp;&nbsp; if(ie4)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sourceObj.setCapture();<BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; if(ff)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP | Event.MOUSEOVER);<BR>&nbsp;&nbsp; }<BR>}</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=1>function MouseMoveToMove(e)<BR>{<BR>&nbsp;beginOpen=false;<BR>&nbsp;if(beginMoving!=true) return false;<BR>&nbsp;if(sourceObj==null)return;<BR>&nbsp;e=e||window.event;<BR>&nbsp;var x = e.clientX-dragClickX;<BR>&nbsp;var y = e.clientY-dragClickY;<BR>&nbsp;sourceObj.style.left = x+"px";<BR>&nbsp;sourceObj.style.top = y+"px";<BR>}<BR>function MouseUpToMove(e)<BR>{<BR>&nbsp;&nbsp;&nbsp; if(sourceObj==null)return;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; if(ie4)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; sourceObj.releaseCapture();<BR>&nbsp;}<BR>&nbsp;sourceObj.style.zIndex=0;<BR>&nbsp;&nbsp;&nbsp; sourceObj.style.top=0;<BR>&nbsp;&nbsp;&nbsp; sourceObj.style.left=0;<BR>&nbsp;&nbsp;&nbsp; beginMoving=false;<BR>&nbsp;window.setTimeout("InsertSwapNode()",20);<BR>}</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=1>function MouseOverToMove(e)<BR>{<BR>&nbsp;&nbsp; if(sourceObj==null)return;<BR>&nbsp;&nbsp; e=e||window.event;<BR>&nbsp;&nbsp; objectObj = e.srcElement||e.target;<BR>}</FONT></P><FONT size=1>下面是广告时间（怎么现在老想做广告-_-)<BR><FONT color=red>99收藏夹,你的个人主页,完全由你做主!</FONT>是一个集个性导航、在线收藏、在线新闻阅读的网站,你能随意的修改配置你的导航页,你能在浏览任何页面时把它加入你的收藏夹,你能够任意的阅读、配置你喜欢的新闻频道并且把你喜欢的新闻拖到你的收藏夹里面永久收藏!你能够浏览、搜索别人的共享收藏,同样的,你只要按住鼠标拖动一下就能够把他永久加入你的在线99收藏夹!本站全部AJAX技术实现,你完全不需要再漫长的等待,所有操作瞬间完成!<BR>如果你希望在浏览任何站点的时候能够单击右键点"收藏到99收藏夹"把这个页面永久的收藏起来,请首先点本站右上角的"下载插件",或者点</FONT><A style="COLOR: blue" href="http://www.99scj.com/regthis.rar"><FONT size=1>这里下载regthis.rar文件</FONT></A><FONT size=1>,在弹出的对话框里面点"保存",再选择一个地方存储起来,下载完后解压缩,再双击运行<FONT color=red>regthis.reg</FONT>文件,再重新启动下你的IE浏览器,很简单的,你以后浏览任何页面都能够在页面上单击右键点"收藏到99收藏夹"就能够把这个页面永久的收入你的"99收藏夹".<BR>本站每天都对数据进行备份,以确保您的数据不会丢失!IE收藏夹只能够在某台电脑上使用,而且如果一旦系统崩溃,你收藏在IE收藏夹里的内容将荡然无存,但是"99收藏夹"不同,数据是保存在我们的服务器上,而且你可以在任何只要能够上网的电脑上使用!你而且能够在线把你IE收藏夹里的内容导入到"99收藏夹".<BR><FONT color=red>关于你的收藏夹:</FONT>如果你登陆了,在左边"我的收藏夹"下面列出的是你的收藏夹的名字,其中"根目录收藏"指你没有分类的收藏,你点任何收藏夹,那么此收藏夹内的收藏就会立即显示出来,你也可以右击某个收藏夹,在弹出的右键菜单里做你想做的修改.你也可以在你的某个收藏上右键,在弹出的菜单里面做你需要的修改.你还可以直接拖动你的收藏,让他们互相变换位置,也可以直接把某一个收藏从某个文件夹拖动到另外个收藏夹.<BR><FONT color=red>关于用户导航模板:</FONT>首先请您登陆,然后你可以点"预览模板",预览模板你能够预览本站已经做好的导航模板,这不会更改您的导航模板,或"插入模板",插入模板指把你选择的模板插在你已经存在的模板的前面,或"更改模板",更改模板指你能够用你选择的模板来更改你现在已有的模板.如果你只想单独的更改某个模板里面的某个链接,请在这个链接上单击右键就是,然后在弹出的对话框里面修改成你所需要的!<BR><FONT color=red>关于你的新闻频道:</FONT>你登陆后就能够在右边看到你订阅的新闻频道了,单击他们会显示你喜欢的新闻,右击能够添加新闻频道,在看新闻的时候你随时可以把你喜欢的新闻拖动到你的某个收藏夹里面永久的收藏起来,一切都是这样的简单.你还可以这样添加你的新闻频道,点左边的RSS新闻频道下面的某个类别,在弹出的面板里面如果看到某个新闻频道你喜欢的话请单击右键,在弹出的右键菜单里选"设置为我的新闻频道"就可以了!<BR><FONT color=red>关于搜索和共享收藏:</FONT>你可以按照用户名搜索某个用户的收藏,也可以按照收藏的标题搜索,也可以按照收藏的链接地址搜索,在搜索的结果里面你能够 任意的拖动你喜欢的收藏到你的收藏夹里面永久的收藏起来,对于共享收藏也可以随意的拖动到你的收藏夹里面,一切都只需要你登陆就可以了!<BR></FONT><img src ="http://www.cnitblog.com/Johncools/aggbug/7531.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-03-13 13:30 <a href="http://www.cnitblog.com/Johncools/articles/7531.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个无刷新二级联动下拉列表,同样适用与firefox,这算ajax么?</title><link>http://www.cnitblog.com/Johncools/articles/6727.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 10:03:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6727.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6727.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6727.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6727.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6727.html</trackback:ping><description><![CDATA[<P><FONT size=1>可能"极好的"又会带来很多的非议,但是我认为这确实很好,我看了大约20个无刷新的连动下拉列表,他们在firefox下面就一团糟.为了这个我差不多搞了两天,就是如果提交窗体后如何保持第二个列表框的值,因为通过js 给下拉框添加条目那么他的状态是不会被保存的,不知道这算ajax么? <BR>测试平台:ie6,firefox <BR>功能:二级无刷新连动 <BR>特点:跨浏览器;提交窗体取第二下拉框的值;数据来源于数据库;以xmlhttp来发送请求,实现无刷新 <BR>请求:如果您能够找到更好的方法请告诉我,非常感谢,您的批评和建议对我是莫大的鼓励 <BR>webform1.aspx: <BR>&lt;%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="drop.WebForm1" %&gt; <BR>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt; <BR>&lt;HTML&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HEAD&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;title&gt;WebForm1&lt;/title&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;meta name="CODE_LANGUAGE" Content="C#"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;meta name="vs_defaultClientScript" content="JavaScript"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;meta name="vs_targetSchema" content="</FONT><A href="http://schemas.microsoft.com/intellisense/ie5"><FONT size=1>http://schemas.microsoft.com/intellisense/ie5</FONT></A><FONT size=1>"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;script language="javascript"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //jb函数会根据不同的浏览器初始化个xmlhttp对象 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function jb() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var A=null; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A=new ActiveXObject("Msxml2.XMLHTTP"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(e) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A=new ActiveXObject("Microsoft.XMLHTTP"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(oc) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A=null <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( !A &amp;&amp; typeof XMLHttpRequest != "undefined" ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A=new XMLHttpRequest() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return A <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //下面Go函数是父列表框改变的时候调用，参数是选择的条目 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function Go(obj) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //得到选择框的下拉列表的value <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var svalue = obj.value; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //定义要处理数据的页面 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var weburl = "webform1.aspx?parent_id="+svalue; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //初始化个xmlhttp对象 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var xmlhttp = jb(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //提交数据，第一个参数最好为get，第三个参数最好为true <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlhttp.open("get",weburl,true); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // alert(xmlhttp.responseText); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //如果已经成功的返回了数据 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlhttp.onreadystatechange=function() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(xmlhttp.readyState==4)//4代表成功返回数据 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var result = xmlhttp.responseText;//得到服务器返回的数据 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //先清空dListChild的所有下拉项 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("dListChild").length = 0; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //给dListChild加个全部型号的,注意是Option不是option <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("dListChild").options.add(new Option("全部型号","0")); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(result!="")//如果返回的数据不是空 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&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; //把收到的字符串按照，分割成数组 <BR>&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; var allArray = result.split(","); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //循环这个数组，注意是从1开始，因为收到的字符串第一个字符是，号，所以分割后第一个数组为空 <BR>&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; for(var i=1;i&lt;allArray.length;i++) <BR>&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; { <BR>&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; //在把这个字符串按照|分割成数组 <BR>&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; var thisArray = allArray[i].split("|"); <BR>&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; //为dListChild添加条目 <BR>&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; document.getElementById("dListChild").options.add(new Option(thisArray[1].toString(),thisArray[0].toString())); <BR>&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; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //发送数据，请注意顺序和参数，参数一定为null或者"" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlhttp.send(null); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/script&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/HEAD&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;body MS_POSITIONING="GridLayout"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;form id="Form1" method="post" runat="server"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:DropDownList onchange="Go(this)" id="dListParent" style="Z-INDEX: 101; LEFT: 248px; POSITION: absolute; TOP: 40px" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; runat="server"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Value="100"&gt;摩托罗拉&lt;/asp:ListItem&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Value="101"&gt;诺基亚&lt;/asp:ListItem&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/asp:DropDownList&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:DropDownList id="dListChild" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 104px" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; runat="server"&gt;&lt;/asp:DropDownList&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 256px; POSITION: absolute; TOP: 176px" runat="server" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Text="Button"&gt;&lt;/asp:Button&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/form&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/body&gt; <BR>&lt;/HTML&gt; <BR><BR>后台webform1.aspx.cs: <BR>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.Configuration;<BR>using System.Data.SqlClient;</FONT></P>
<P><FONT size=1>namespace drop<BR>{<BR>&nbsp;/// &lt;summary&gt;<BR>&nbsp;/// WebForm1 的摘要说明。<BR>&nbsp;/// &lt;/summary&gt;<BR>&nbsp;public class WebForm1 : System.Web.UI.Page<BR>&nbsp;{<BR>&nbsp;&nbsp;protected System.Web.UI.WebControls.DropDownList dListParent;<BR>&nbsp;&nbsp;protected System.Web.UI.WebControls.Button Button1;<BR>&nbsp;&nbsp;protected System.Web.UI.WebControls.DropDownList dListChild;<BR>&nbsp;<BR>&nbsp;&nbsp;private void Page_Load(object sender, System.EventArgs e)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;// 在此处放置用户代码以初始化页面<BR>&nbsp;&nbsp;&nbsp;//if(!IsPostBack)<BR>&nbsp;&nbsp;&nbsp;//{<BR>&nbsp;&nbsp;&nbsp;&nbsp;BindDrop();//这里不能够放到if(!IsPostBack)里面<BR>&nbsp;&nbsp;&nbsp;//}<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;protected void BindDrop()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//首先我想父dropdownlist也绑定数据库,后面想没必要<BR>&nbsp;&nbsp;&nbsp;//if(!IsPostBack)<BR>&nbsp;&nbsp;&nbsp;//{<BR>&nbsp;&nbsp;&nbsp;&nbsp;//绑定父dListParent<BR>&nbsp;&nbsp;&nbsp;//&nbsp;BindParent();<BR>&nbsp;&nbsp;&nbsp;//}<BR>&nbsp;&nbsp;&nbsp;&nbsp; //获得传递过来的parent_id值,如果是第一次请求他为null<BR>&nbsp;&nbsp;&nbsp;string str = Request.QueryString["parent_id"];<BR>&nbsp;&nbsp;&nbsp;string str1 = dListParent.SelectedValue;;<BR>&nbsp;&nbsp;&nbsp;//Response.Write(str1);<BR>&nbsp;&nbsp;&nbsp;//如果str加个字符串!=原来的字符串则说明触发过dListParent的onchange事件<BR>&nbsp;&nbsp;&nbsp;if((str+"abc")!="abc")<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //绑定 dListChild控件<BR>&nbsp;&nbsp;&nbsp;&nbsp;BindChild(str);//把传来的父DropDownList的value做为参数<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;BindParent(str1);<BR>&nbsp;&nbsp;}</FONT></P>
<P><BR><FONT size=1>&nbsp;&nbsp;protected void BindParent(string str)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//如果是第一次请求或者是刷新这个页面则根据dListParent的值来选择<BR>&nbsp;&nbsp;&nbsp;//把参数转化成int<BR>&nbsp;&nbsp;&nbsp;int i = Convert.ToInt32(str);<BR>&nbsp;&nbsp;&nbsp;dListChild.Items.Clear();<BR>&nbsp;&nbsp;&nbsp;dListChild.Items.Add(new ListItem("全部型号","0"));<BR>&nbsp;&nbsp;&nbsp;//得到数据库连接字符串<BR>&nbsp;&nbsp;&nbsp;string connStr = ConfigurationSettings.AppSettings["ConnString"].ToString();<BR>&nbsp;&nbsp;&nbsp;//初始化个conn对象<BR>&nbsp;&nbsp;&nbsp;SqlConnection conn = new SqlConnection(connStr);<BR>&nbsp;&nbsp;&nbsp;//数据库语句<BR>&nbsp;&nbsp;&nbsp;string commStr = string.Format("select type_value,type_text from phone_type where parent_id={0}",i);<BR>&nbsp;&nbsp;&nbsp;//建立数据库命令对象<BR>&nbsp;&nbsp;&nbsp;SqlCommand comm = new SqlCommand(commStr,conn);<BR>&nbsp;&nbsp;&nbsp;//打开数据库<BR>&nbsp;&nbsp;&nbsp;conn.Open();<BR>&nbsp;&nbsp;&nbsp;//执行命令<BR>&nbsp;&nbsp;&nbsp;SqlDataReader dr = comm.ExecuteReader();<BR>&nbsp;&nbsp;&nbsp;//循环dr，给dListParent添加条目<BR>&nbsp;&nbsp;&nbsp;while(dr.Read())<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dListChild.Items.Add(new ListItem(dr[1].ToString(),dr[0].ToString()));<BR>&nbsp;&nbsp;&nbsp;&nbsp;//也可以这样<BR>&nbsp;&nbsp;&nbsp;&nbsp;//dListParent.Items.Add(new ListItem(dr["phone_text"].ToString(),dr["phone_value"].ToString()));<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;//添加下面这话的意思是当点提交按钮提交窗体的时候第二个dListChild的状态能够得到保存<BR>&nbsp;&nbsp;&nbsp;dListChild.SelectedValue = Request.Form["dListChild"];<BR>&nbsp;&nbsp;&nbsp;dr.Close();<BR>&nbsp;&nbsp;&nbsp;conn.Close();<BR>&nbsp;&nbsp;}</FONT></P>
<P><BR><FONT size=1>&nbsp;&nbsp;protected void BindChild(string str)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp; //通过js给包括dropdownlist任何控件添加的内容不会被保存状态<BR>&nbsp;&nbsp;&nbsp;//把参数转化成int<BR>&nbsp;&nbsp;&nbsp;int i = Convert.ToInt32(str);<BR>&nbsp;&nbsp;&nbsp;//定义个字符串用保存从数据库返回的数据<BR>&nbsp;&nbsp;&nbsp;string result = "";<BR>&nbsp;&nbsp;&nbsp;//先清空输出的东西<BR>&nbsp;&nbsp;&nbsp;Response.Clear();<BR>&nbsp;&nbsp;&nbsp;string connStr = ConfigurationSettings.AppSettings["ConnString"].ToString();<BR>&nbsp;&nbsp;&nbsp;SqlConnection conn = new SqlConnection(connStr);<BR>&nbsp;&nbsp;&nbsp;SqlCommand comm = conn.CreateCommand();<BR>&nbsp;&nbsp;&nbsp;string commStr = string.Format("select type_value,type_text from phone_type where parent_id = {0}",i);<BR>&nbsp;&nbsp;&nbsp;comm.CommandText = commStr;<BR>&nbsp;&nbsp;&nbsp;conn.Open();<BR>&nbsp;&nbsp;&nbsp;SqlDataReader dr = comm.ExecuteReader();<BR>&nbsp;&nbsp;&nbsp;while(dr.Read())<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;result += ","+dr[0].ToString() +"|" + dr[1].ToString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;//dListChild.Items.Add(new ListItem(dr[1].ToString(),dr[0].ToString()));<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;//把从数据库得到的信息输出到客户端<BR>&nbsp;&nbsp;&nbsp;Response.Write(result);<BR>&nbsp;&nbsp;&nbsp;//输出完成关闭Response,以免造成不必要的输出<BR>&nbsp;&nbsp;&nbsp;Response.Flush();<BR>&nbsp;&nbsp;&nbsp;Response.Close();<BR>&nbsp;&nbsp;&nbsp;dr.Close();<BR>&nbsp;&nbsp;&nbsp;conn.Close();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;#region Web 窗体设计器生成的代码<BR>&nbsp;&nbsp;override protected void OnInit(EventArgs e)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;InitializeComponent();<BR>&nbsp;&nbsp;&nbsp;base.OnInit(e);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;/// &lt;summary&gt;<BR>&nbsp;&nbsp;/// 设计器支持所需的方法 - 不要使用代码编辑器修改<BR>&nbsp;&nbsp;/// 此方法的内容。<BR>&nbsp;&nbsp;/// &lt;/summary&gt;<BR>&nbsp;&nbsp;private void InitializeComponent()<BR>&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;this.Button1.Click += new System.EventHandler(this.Button1_Click);<BR>&nbsp;&nbsp;&nbsp;this.Load += new System.EventHandler(this.Page_Load);</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;#endregion</FONT></P>
<P><FONT size=1>&nbsp;&nbsp;private void Button1_Click(object sender, System.EventArgs e)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;Response.Write(Request.Form["dListChild"].ToString());<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}<BR></FONT></P>
<P><FONT size=1></FONT>&nbsp;</P>
<P><FONT face="Times New Roman" color=#000000 size=1>数据表:<BR>主键id&nbsp;&nbsp;&nbsp;&nbsp; parent_id(int)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type_value(int)&nbsp;&nbsp;&nbsp;&nbsp; type_text(varchar)<BR>int递增&nbsp;&nbsp; 父下拉框的value值&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下拉框的value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下拉框的text<BR></FONT></P><FONT size=1><IMG height=1 src="http://pwqzc.cnblogs.com/aggbug/252175.html" width=1><BR><BR></FONT>
<DIV align=right><FONT size=1>一帆(老鼠粮仓之路) 2005-10-11 10:21 </FONT></DIV><img src ="http://www.cnitblog.com/Johncools/aggbug/6727.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 18:03 <a href="http://www.cnitblog.com/Johncools/articles/6727.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX急速狂飙:开发www.99scj.com体验(1)</title><link>http://www.cnitblog.com/Johncools/articles/6704.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6704.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6704.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6704.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6704.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6704.html</trackback:ping><description><![CDATA[借用了梅花兄的一个惯用语:急速狂飙.<BR>首先我来说说对ajax.net和atlas的比较吧!免得朋友们在一些方面犯和我同样的错误,当然,这也仅仅代表了我的体会和个人观点<BR>1,如果你是使用forms验证,在一个未容许的页面会出现js名字空间未定义的错误,这对于ajax.net还是atlas来说都是一样的,解决办法是先容许所有用户,再单独在web.config里面设置权限<BR>2,在速度,性能,稳定性上面atlas稍微比ajax.net胜一筹.<BR>3,ajax.net支持同步传输数据,也支持异步传输数据,但是atlas只支持异步传输数据,所以你如果想控制js代码的流程的话ajax.net比atlas要强,但是ajax.net 在异步传输上有个特点,不容许在同一时间多次调用同一服务器类,我的解决办法是另外写个类<BR>4,ajax.net和atlas都能够从服务器返回个DataTable,但是在客户端接收的方法不同,下面是一个小例子,假设var dt =服务器返回的DataTable<BR>对于ajax.net 的方法是:<BR>if(dt.Rows.length&gt;0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.style.display="";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.innerHTML="";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(var row=0;row&lt;dt.Rows.length;row++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var cur = dt.Rows[row];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.innerHTML+="&lt;li&gt;&lt;a href='javascript:void(0)' type="+cur.this_url+" id="+cur.this_id+" onclick='getRssNews(this.type,this);' oncontextmenu='return showMyRightRssDiv(event);' onfocus='this.blur();'&gt;"+cur.this_title+"&lt;/a&gt;&lt;/li&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("pageIndexTd").innerHTML="&amp;nbsp;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>在ajax中取得服务器返回的datatable的 行数是dt.Rows.length,但是atlas是dt.get_length()<BR>在ajax.net中得到某一行是dt.Rows[i],而atlas是dt.getItem(i)<BR>在ajax.net中得到某行某列是dt.Rows[i].title,其中 title是列名,而atlas是dt.getItem(i).getProperty("title"),其中title是列名&nbsp; <BR><IMG height=1 src="http://pwqzc.cnblogs.com/aggbug/331706.html" width=1><BR><BR>
<DIV align=right>一帆(老鼠粮仓之路) 2006-02-16 11:58 </DIV><BR>文章来源:<A href="http://pwqzc.cnblogs.com/archive/2006/02/16/331706.html">http://pwqzc.cnblogs.com/archive/2006/02/16/331706.html</A><img src ="http://www.cnitblog.com/Johncools/aggbug/6704.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6704.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠之Atlas之旅(一):Atlas官方站点</title><link>http://www.cnitblog.com/Johncools/articles/6723.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6723.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6723.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6723.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6723.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6723.html</trackback:ping><description><![CDATA[1,<A href="http://msdn.microsoft.com/asp.net/future/">MSDN上的Atlas 网站</A> <BR>稍微翻译下: <BR><A style="FONT-WEIGHT: bold" href="/admin/atlastemplate/default.aspx">Installing the ASP.NET "Atlas" Web Site Template</A> 
<P><SPAN style="COLOR: #000000">Step-by-step instructions to help you download and install the ASP.NET "Atlas" Web Site Template, and to create your first Web site using it.&nbsp;</SPAN>&nbsp; <BR>一步步告诉你怎么去下载及安装atlas,而且怎么样去创建你的第一个atlas站点<BR><A style="FONT-WEIGHT: bold" href="/admin/atlashol/default.aspx">Installing the Hands-on Lab ASP.NET "Atlas" Web Site Template</A> </P>
<P><SPAN style="COLOR: #000000">Step-by-step instructions to help you download and install the ASP.NET "Atlas" hands-on lab.&nbsp;</SPAN>&nbsp;<BR>一步步告诉你怎么下载及安装atlas教程<BR>2,<A class="" title="" href="http://beta.asp.net/default.aspx?tabindex=7&amp;tabid=47" target=_blank>ASP.NET "Atlas" 官方网站</A><BR>3,,<A class="" title="" href="http://atlas.asp.net/docs/default.aspx" target=_blank><FONT color=#000080>ASP.NET "Atlas" 预览文档</FONT></A><BR>4,<A class="" title="" href="http://atlas.asp.net/quickstart/default.aspx" target=_blank><FONT color=#000080>Atlas&nbsp; 快速入门教程</FONT></A><BR><BR></P><img src ="http://pwqzc.cnblogs.com/aggbug/260592.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-10-24 10:28 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/10/24/260592.html'>http://pwqzc.cnblogs.com/archive/2005/10/24/260592.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6723.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6723.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠之Atlas之旅(二):下载安装篇</title><link>http://www.cnitblog.com/Johncools/articles/6722.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6722.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6722.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6722.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6722.html</trackback:ping><description><![CDATA[<P>在师傅的鼓励下,我的劲头越来越足拉!!! <BR>首先要下载安装vs2005,地址是:http://www.586cn.com/down/soft/23703.html <BR>我找了一天才找到的,是beta2的版本,我为了找他花了可5个小时啊 <BR>使用了emule,比特之类的东西. <BR>2,下载atlas; <BR>下载地址是:http://msdn.microsoft.com/asp.net/future/atlastemplate/default.aspx <BR>找到里面的"Download either the <A href="http://lab.msdn.microsoft.com/vs2005/eula.aspx?id=3b00744e-dd4a-4155-9563-14d501c421e4">Beta 2</A> or the <A href="http://lab.msdn.microsoft.com/vs2005/eula.aspx?id=63C6B54B-AF8F-453B-869B-0438DBBB781B">RTM</A> VSI file for creating "字样,点 beta2,进入另外个页面, <BR>点下面的accept他就会自动下载拉,是个aspnetatlas.vsi文件 </P>
<P>3,先安装vsnet2005,这不说拉<BR><BR>我下了两天，安装好之后，双击vsi文件竟然没有反映啊！！！晕死，后面在网上找资料<FONT style="COLOR: #ffffff; BACKGROUND-COLOR: #ffffff" color=#808080><SPAN style="BACKGROUND-COLOR: #ff0000"><FONT style="COLOR: #ff0000; BACKGROUND-COLOR: #000000" color=#808080>才发现.vsi扩展名文件的安装，其实质是调用C:\Program Files\Common Files\Microsoft Shared\MSEnv目录下的VSContentInstaller.exe进行安装的。我一找我的这个目录，晕死，我才发现我的目录下根本就没有这个文件啊！怪事，后面一看我的vs2005的大小，是3.15G，那绝对是我的安装文件有问题拉，因为其他的是3.5G，所以我又只能够重新bt下载。<BR><BR><BR></FONT></SPAN><BR></FONT><BR>4,安装atlas,等下,我的vsnet2005正在下载呢.<BR>看<A href="http://msdn.microsoft.com/asp.net/future/atlastemplate/default.aspx">http://msdn.microsoft.com/asp.net/future/atlastemplate/default.aspx</A>上的安装说明,我简单翻译下:<BR>呵呵,还是在吴旗娃师傅的指教下完成的啊<BR>1&gt;下载beta 2或者RTM的vsi文件,以便你去创建一个新的空白的atlas站点.你可能需要把本页的安装说明拷贝到你的机器上,以便你安装的时候参考<BR>2&gt;下载完后,双击ASPNETAtlas.VSI 文件开始安装<BR>3&gt;在出现"Choose Content to install"窗口的时候,你可以选择for vb,或者c#或者both,并且确保各自的选择框被选上.<BR>4&gt;单击下一步<BR>5&gt;如果你碰到警告窗口说你的内容没有被签名,问你是否继续的时候请选择yes<BR>6&gt;单击finish<BR>7&gt;单击完成<BR></P><IMG height=1 src="http://pwqzc.cnblogs.com/aggbug/260839.html" width=1><BR><BR>
<DIV align=right>一帆(老鼠粮仓之路) 2005-10-24 14:16 </DIV><BR>文章来源:<A href="http://pwqzc.cnblogs.com/archive/2005/10/24/260839.html">http://pwqzc.cnblogs.com/archive/2005/10/24/260839.html</A><img src ="http://www.cnitblog.com/Johncools/aggbug/6722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（四）：提交、返回复杂数据类型给web 服务</title><link>http://www.cnitblog.com/Johncools/articles/6720.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6720.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6720.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6720.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6720.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6720.html</trackback:ping><description><![CDATA[除了传递和返回简单的类型，如字符串和整数型给web 服务，你也可以传递和返回复杂类型例如你的Web服务类。<BR><BR>下面是asmx的代码：<BR><BR><PRE><FONT color=blue><B><FONT color=blue>&lt;%</FONT>@ WebService Language="C#" Class="Quickstart.Samples.ComplexService" <FONT color=blue>%&gt;</FONT></B></FONT>

<FONT color=blue>using</FONT> System;
<FONT color=blue>using</FONT> System.Web;
<FONT color=blue>using</FONT> System.Collections;
<FONT color=blue>using</FONT> System.Web.Services;
<FONT color=blue>using</FONT> System.Web.Services.Protocols;

<FONT color=blue>using</FONT> Quickstart.Samples;//注意这里要using

<FONT color=blue>namespace</FONT> Quickstart.Samples
{
    <FONT color=blue>public</FONT> <FONT color=blue>class</FONT> Animal
    {
        String _name;
        String _color;

        <FONT color=blue>public</FONT> String Name
        {
            <FONT color=blue>get</FONT> { <FONT color=blue>return</FONT> _name; }
            <FONT color=blue>set</FONT> { _name = value; }
        }

        <FONT color=blue>public</FONT> String Color
        {
            <FONT color=blue>get</FONT> { <FONT color=blue>return</FONT> _color; }
            <FONT color=blue>set</FONT> { _color = value; }
        }
    };    
    
    
    [WebService(Namespace = "http:<FONT color=green>//tempuri.org/")]</FONT>
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    <FONT color=blue>public</FONT> <FONT color=blue>class</FONT> ComplexService : System.Web.Services.WebService
    {
        [WebMethod]
        <FONT color=blue>public</FONT> Animal EchoAnimal(Animal a)
        {
            <FONT color=blue>return</FONT> a;//这里传递和返回的都是个Animal对象
        }
    }

}<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
下面是aspx页面的代码：<BR><BR><PRE><FONT color=blue>&lt;!</FONT><FONT color=maroon>DOCTYPE</FONT> html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"<FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>html</FONT> xmlns="http://www.w3.org/1999/xhtml"<FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>head</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>title</FONT><FONT color=blue>&gt;</FONT>Complex Type Service<FONT color=blue>&lt;/</FONT><FONT color=maroon>title</FONT><FONT color=blue>&gt;</FONT>

    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" <FONT color=blue>/&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" <FONT color=blue>/&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script3" runat="server" Path="~/ScriptLibrary/Atlas.js"<FONT color=blue>/&gt;</FONT>

    <FONT color=green>&lt;!-- get script proxy --&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>script</FONT> type="text/javascript" language="JavaScript" src="ComplexService.asmx/js"<FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>script</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;/</FONT><FONT color=maroon>head</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>body</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>h3</FONT><FONT color=blue>&gt;</FONT>
        Name:<FONT color=blue>&lt;</FONT><FONT color=maroon>input</FONT> id="inputName" <FONT color=blue>/&gt;</FONT>
        Color:<FONT color=blue>&lt;</FONT><FONT color=maroon>input</FONT> id="inputColor" <FONT color=blue>/&gt;</FONT>
        <FONT color=blue>&lt;</FONT><FONT color=maroon>button</FONT> id="buttonGo" onclick="return OnbuttonGo_click()"<FONT color=blue>&gt;</FONT>GO<FONT color=blue>&lt;/</FONT><FONT color=maroon>button</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>h3</FONT><FONT color=blue>&gt;</FONT>

    <FONT color=blue>&lt;</FONT><FONT color=maroon>script</FONT> type="text/javascript" language="JavaScript"<FONT color=blue>&gt;</FONT>
    function OnbuttonGo_click() 
    {
        //Call script proxy passing the input element data

        var i1 = document.getElementById('inputName');
        var i2 = document.getElementById('inputColor');
        //先new一个web 服务中的Animal对象
        var object = new Quickstart.Samples.Animal();<BR><BR>       //给这个对象的属性赋值
        object.Name = i1.value;
        object.Color = i2.value. 
        //传递的是一个Animal对象
        requestComplexService = Quickstart.Samples.ComplexService.EchoAnimal(
            object,         //params
            OnComplete,     //Complete event
            OnTimeout       //Timeout event
            );

        return false;
    }
    
    function OnComplete(result) 
    {
        <BR> //你可以直接在js里获得他的属性<BR>alert("Name= " + result.Name + " Color= " + result.Color);
    }

    function OnTimeout(result) 
    {
        alert("Timed out");
    }
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>script</FONT><FONT color=blue>&gt;</FONT>

<FONT color=blue>&lt;/</FONT><FONT color=maroon>body</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;/</FONT><FONT color=maroon>html</FONT><FONT color=blue>&gt;</FONT>
</PRE></PRE><img src ="http://pwqzc.cnblogs.com/aggbug/263698.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-10-28 11:33 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/10/28/263698.html'>http://pwqzc.cnblogs.com/archive/2005/10/28/263698.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6720.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6720.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（三）：调用简单web服务</title><link>http://www.cnitblog.com/Johncools/articles/6721.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6721.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6721.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6721.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6721.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6721.html</trackback:ping><description><![CDATA[vs2005还没有下完，等不急拉，先翻译下atlas里面的web服务，原文地址：<BR><BR><A href="http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx">http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx</A><BR></A>翻译的不是很好，还请提出更好的翻译，谢谢<BR><BR>asp.net Atlas容许你的web程序从浏览器（客户端）调用正规的web 服务，这给web程序带来了丰富的用户体验，因为他不需要象传统方法一样需要通过postback把窗体提交给服务器而仅仅是在浏览器和服务器之间传递你所需要的数据。<BR><BR>ASP.NET 'Atlas' 通过浏览器从Web服务中访问JavaScript代理而提供了一种访问和使用Web服务的基本方法。 <BR><BR>一，从aspx页面调用简单的web服务<BR>1，在站点里添加个web服务，给里面你想调用的方法加上[WebMethod]特性，因为这样你才可以从外部访问，下面是个简单的web服务：<BR><PRE><FONT color=blue><B><FONT color=blue>&lt;%</FONT>@ WebService Language="C#" Class="Quickstart.Samples.SimpleService" <FONT color=blue>%&gt;</FONT></B></FONT>

<FONT color=blue>using</FONT> System;
<FONT color=blue>using</FONT> System.Web;
<FONT color=blue>using</FONT> System.Collections;
<FONT color=blue>using</FONT> System.Web.Services;
<FONT color=blue>using</FONT> System.Web.Services.Protocols;

<FONT color=blue>namespace</FONT> Quickstart.Samples
{
    [WebService(Namespace = "http:<FONT color=green>//tempuri.org/")]</FONT>
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    <FONT color=blue>public</FONT> <FONT color=blue>class</FONT> SimpleService : System.Web.Services.WebService
    {
        [WebMethod]
        <FONT color=blue>public</FONT> <FONT color=blue>string</FONT> EchoString(<FONT color=blue>string</FONT> s)
        {
            <FONT color=blue>return</FONT> s;
        }
    }

}
</PRE>2，在你的web 页面添加下列的atlas:Script以便在页面里激活asp.net Atlas，当你的页面被请求的时候他们会被下载。<BR><BR>&lt;atlas:Script ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" /&gt;<BR>&lt;atlas:Script ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" /&gt;<BR>&lt;atlas:Script ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasRuntime.js"/&gt;<BR><BR><BR>3，在web页面添加一个javascript语句用他的src属性指向web 服务，当你的页面被请求的时候.asmx/js 条目将下载javascript代理：<BR><BR>&lt;script language="JavaScript" src="SimpleService.asmx/js"&gt;<BR><BR><BR>4，现在你可以从你的页面中调用web 服务中的方法了，他是基于事件驱动的，他有三个参数，第一个是web服务中的方法所需要的参数，第二个参数是数据成功返回所激发的操作（函数），第三个参数是返回数据超时所激发的操作（函数）：<BR><BR>Quickstart.Samples.SimpleService.EchoString(<BR>&nbsp;&nbsp;&nbsp; "SomeText",&nbsp;&nbsp;&nbsp;&nbsp; //params<BR>&nbsp;&nbsp;&nbsp; OnComplete,&nbsp;&nbsp;&nbsp;&nbsp; //Complete event<BR>&nbsp;&nbsp;&nbsp; OnTimeout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Timeout event<BR>&nbsp;&nbsp;&nbsp; );<BR><BR><BR>5，你甚至可以直接传递html input控件的值给web 服务中的方法<BR><BR>Quickstart.Samples.SimpleService.EchoString(<BR>&nbsp;&nbsp;&nbsp; document.getElementById('inputName').value,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //params<BR>&nbsp;&nbsp;&nbsp; OnComplete,&nbsp;&nbsp;&nbsp;&nbsp; //Complete event<BR>&nbsp;&nbsp;&nbsp; OnTimeout&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Timeout event<BR>&nbsp;&nbsp;&nbsp; );<BR><BR><BR>6，在成功获得数据的操作函数中，有个result参数，这个就是调用web服务方法而返回的数据，如果响应超时，将激发OnTimeOut操作；<BR><BR>&nbsp;function OnComplete(result) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(result);<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp; function OnTimeout(result) <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("Timed out");<BR>&nbsp;&nbsp;&nbsp; }<BR><BR><BR>好了，下面是aspx页面的代码：<BR><BR><PRE><FONT color=blue>&lt;!</FONT><FONT color=maroon>DOCTYPE</FONT> html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"<FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>html</FONT> xmlns="http://www.w3.org/1999/xhtml"<FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>head</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>title</FONT><FONT color=blue>&gt;</FONT>Simple Service<FONT color=blue>&lt;/</FONT><FONT color=maroon>title</FONT><FONT color=blue>&gt;</FONT>

    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" <FONT color=blue>/&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" <FONT color=blue>/&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>atlas:Script</FONT> ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasRuntime.js"<FONT color=blue>/&gt;</FONT>

    <FONT color=green>&lt;!-- get script proxy --&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>script</FONT> type="text/javascript" language="JavaScript" src="SimpleService.asmx/js"<FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>script</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;/</FONT><FONT color=maroon>head</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;</FONT><FONT color=maroon>body</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;</FONT><FONT color=maroon>h3</FONT><FONT color=blue>&gt;</FONT>
        Enter your name:<FONT color=blue>&lt;</FONT><FONT color=maroon>input</FONT> id="inputName" <FONT color=blue>/&gt;</FONT>
        <FONT color=blue>&lt;</FONT><FONT color=maroon>button</FONT> id="buttonGo" onclick="return OnbuttonGo_click()"<FONT color=blue>&gt;</FONT>GO<FONT color=blue>&lt;/</FONT><FONT color=maroon>button</FONT><FONT color=blue>&gt;</FONT>
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>h3</FONT><FONT color=blue>&gt;</FONT>

    <FONT color=blue>&lt;</FONT><FONT color=maroon>script</FONT> type="text/javascript" language="JavaScript"<FONT color=blue>&gt;</FONT>
    function OnbuttonGo_click() 
    {
        //Call script proxy passing the input element data
        requestSimpleService = Quickstart.Samples.SimpleService.EchoString(
            document.getElementById('inputName').value,       //params
            OnComplete,     //Complete event
            OnTimeout       //Timeout event
            );
        return false;
    }
    
    function OnComplete(result) 
    {
        alert(result);
    }

    function OnTimeout(result) 
    {
        alert("Timed out");
    }
    <FONT color=blue>&lt;/</FONT><FONT color=maroon>script</FONT><FONT color=blue>&gt;</FONT>

<FONT color=blue>&lt;/</FONT><FONT color=maroon>body</FONT><FONT color=blue>&gt;</FONT>
<FONT color=blue>&lt;/</FONT><FONT color=maroon>html</FONT><FONT color=blue>&gt;</FONT>
</PRE><BR><BR><BR><img src ="http://pwqzc.cnblogs.com/aggbug/263685.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-10-28 11:22 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/10/28/263685.html'>http://pwqzc.cnblogs.com/archive/2005/10/28/263685.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Atlas—微软的Ajax工具包(来自MSDN  Scott Guthrie）</title><link>http://www.cnitblog.com/Johncools/articles/6719.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6719.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6719.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6719.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6719.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6719.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">微软现在已经进入了</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>Visual Web Developer 2005</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">发布版最后的</SPAN><SPAN lang=EN-US><FONT face=Georgia>RTM</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">里程碑时刻。为了达到</SPAN><SPAN lang=EN-US><FONT face=Georgia>ZBB</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">（</SPAN><SPAN lang=EN-US><FONT face=Georgia>Zero Bug Bounce</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">），微软已经锁定了这些产品的特性，着重优化最终的质量、性能和可靠性。</SPAN><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">与此同时，微软开始了下一个发布版本的研发，其中一个重要的研究方向就是通过</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的编程在浏览器中实现日益流行的富客户端应用。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">今后的</SPAN><SPAN lang=EN-US><FONT face=Georgia>IE</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中将拥有</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">所需的所有东西</SPAN><SPAN lang=EN-US><FONT face=Georgia>——DHTML</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">、</SPAN><SPAN lang=EN-US><FONT face=Georgia>JScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>XmlHttp</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">。实际上</SPAN><SPAN lang=EN-US><FONT face=Georgia>Outlook Web Access</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">从</SPAN><SPAN lang=EN-US><FONT face=Georgia>1998</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">年开始就已经提供了这种伟大的浏览体验了。在</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中，微软使用异步回调及舒适的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的应用程序的编写更加简单，并且，微软为此提供了大量的内建控件。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">目前，几乎所有的浏览器都提供了</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">所需的技术，使用这种模式的富客户端应用程序也不断出现。今天，世界上出现了不计其数的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的站点，包括</SPAN><SPAN lang=EN-US><FONT face=Georgia>Google</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的很多站点、</SPAN><SPAN lang=EN-US><FONT face=Georgia>A9</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>Flickr</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">。微软的很多站点也使用了这项技术，如</SPAN><SPAN lang=EN-US><FONT face=Georgia>Start.com</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>MSN Virtual Earth</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">项目。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的风行说明用户对于丰富的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">体验的需求日益增长。然而，开发和调试</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序是一项非常艰难的工作。要编写一个丰富的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，开发者需要详细地掌握</SPAN><SPAN lang=EN-US><FONT face=Georgia>DHTML</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>JavaScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，并且还要掌握各种浏览器之间在设计细节上的不同。然而没有哪些工具能够简化这些应用程序的设计和开发。最后，调试和测试这些应用程序会变得异常困难。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">微软致力于简化</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用的开发，并提供丰富的、可交互的和个性化的用户体验。开发者可以对客户端脚本不甚了解；但他们可以无缝地将浏览器</SPAN><SPAN lang=EN-US><FONT face=Georgia>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">与他们编写的其他应用无缝地集成在一起，并且他们可以很容易地开发和调试这些应用程序。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">出于这一目的，微软启动了一个新的项目，研发代号为&#8220;</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">&#8221;。同时，微软还启动了一个站点来持续更新其核心进展和示例，并围绕它建立一个活跃的社区。在</SPAN><SPAN lang=EN-US><FONT face=Georgia>9</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">月份的</SPAN><SPAN lang=EN-US><FONT face=Georgia>PDC</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">大会上，开发者可以看到</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的技术预览版。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">以下是</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">所拥有的特性。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架</SPAN><FONT face=Georgia> <SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架是可扩展的、</SPAN><SPAN lang=EN-US><FONT face=Georgia>100%</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">面向对象的</SPAN><SPAN lang=EN-US><FONT face=Georgia>JavaScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架，允许开发者很容易地构建拥有丰富的</SPAN><SPAN lang=EN-US><FONT face=Georgia>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">功能并且可以连接</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格浏览器应用程序。使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，开发者可以使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>DHTML</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">、</SPAN><SPAN lang=EN-US><FONT face=Georgia>JavaScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>XMLHTTP</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">来编写</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序，而无须掌握这些技术的细节。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架可以在所有的现代浏览器上运行，不论使用的是什么</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">服务器。它还完全不需要安装，只要在页面中引用正确的脚本文件即可。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架包含下列组件：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一个可扩展的核心框架，其中为</SPAN><SPAN lang=EN-US><FONT face=Arial>JavaScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">添加了很多新特性，如生存期管理、继承、多播事件处理器和接口</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一个基础类库，提供了通用特性，如丰富的字符串操作功能、计时器和运行任务等</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一个</SPAN><SPAN lang=EN-US><FONT face=Arial>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">框架，可以跨浏览器实现</SPAN><SPAN lang=EN-US><FONT face=Arial>HTML</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">的动态行为</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一个网络栈，用于简化对服务器的连接和对</SPAN><SPAN lang=EN-US><FONT face=Arial>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">的访问</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一组具有丰富</SPAN><SPAN lang=EN-US><FONT face=Arial>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">功能的控件，如自动完成文本框、弹出面板、动画控件和拖放</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">一个浏览器兼容的层（</SPAN><SPAN lang=EN-US><FONT face=Arial>Layer</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">），用于在不同浏览器中定位不同的脚本行为</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">服务器控件</SPAN><FONT face=Georgia> <SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">对于</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序，微软专门设计了一组</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的服务器控件，并且加强了现有的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">页面框架和控件，以便支持</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中有一项称作异步客户端回调（</SPAN><SPAN lang=EN-US><FONT face=Georgia>Asynchronous Client Callbacks</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">）的新特性，使得构建从服务器上更新内容时不会引发页面中断的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">页面变得很容易。异步客户端回调包装了</SPAN><SPAN lang=EN-US><FONT face=Georgia>XMLHTTP</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，能够在很多浏览器上工作。</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">本身就包括了很多使用回调的控件，包括具有客户端分页和排序功能的</SPAN><SPAN lang=EN-US><FONT face=Georgia>GridView</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>DetalsView</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">控件，以及</SPAN><SPAN lang=EN-US><FONT face=Georgia>TreeView</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">控件的虚拟列表支持。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端脚本框架将完全支持</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">回调，但微软希望在今后进一步增强浏览器和服务器之间的集成性。例如，你可以将</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端控件的数据绑定并指定为服务器上的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">数据源控件，并且可以从客户端异步地控制</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">页面的个性化特征。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><FONT face=Georgia>ASP.NET Web Services</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">集成</SPAN><SPAN lang=EN-US><FONT face=Georgia><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><o:p></o:p></FONT></SPAN></B></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和任何客户端应用程序一样，一个</SPAN><SPAN lang=EN-US><FONT face=Georgia>Ajax</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">风格的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序通常也需要访问</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">服务器的一些功能。</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序连接服务器的模型和其他平台类似，都是使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">来实现。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">通过</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">集成，</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序将可以在任何支持</SPAN><SPAN lang=EN-US><FONT face=Georgia>XMLHTTP</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的浏览器上通过</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端用本框架来直接访问任何宿主了</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的</SPAN><SPAN lang=EN-US><FONT face=Georgia>asmx</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">或</SPAN><SPAN lang=EN-US><FONT face=Georgia>Indigo</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">服务。该框架将会自动处理、代理和脚本到对象、对象到脚本的序列化问题。通过使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">集成，开发者可以使用单一的编程模型来编写</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，并且在任何应用程序中使用它们，不论是基于浏览器的站点上还是智能客户端应用程序中。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">构建块</SPAN><FONT face=Georgia> <SPAN lang=EN-US><o:p></o:p></SPAN></FONT></B></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">在</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中，微软构建了一组丰富的构建块服务（</SPAN><SPAN lang=EN-US><FONT face=Georgia>Building Block Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">），这使得构建强大、个性化的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序变得不可思议的简单。这些构建块极大地降低了在开发通用的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序过程中需要编写的代码数量，比如管理用户、通过角色验证用户和存储用户的个性化设置信息等。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，我们可以在任何浏览器上的任何客户端应用程序中向访问</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web Services</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">那样访问这些功能。例如，如果你正在开发一个站点来显示用户的</SPAN><SPAN lang=EN-US><FONT face=Georgia>TO-DO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">项目，你可以使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Profile</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">服务来将他们存放在服务器上的用户自定义配置文件中。这样，即使用户从一台机器转移到另一台机器上，也同样可以访问这些项目。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">微软将提供的服务包括（全部是基于</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">的）：</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN lang=EN-US><FONT face=Arial>Profile</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">：在服务器上存放每个用户特有的数据</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN lang=EN-US><FONT face=Arial>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">个性化：在服务器上存放个性化的</SPAN><SPAN lang=EN-US><FONT face=Arial>UI</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">设置信息</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">验证：验证用户</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=a style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN lang=EN-US style="FONT-FAMILY: Wingdings; mso-fareast-font-family: Wingdings; mso-bidi-font-family: Wingdings"><SPAN style="mso-list: Ignore"><FONT size=2>l</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><FONT size=2><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial">角色：基于用户的角色验证用户任务和提供不同的</SPAN><SPAN lang=EN-US><FONT face=Arial>UI<o:p></o:p></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">由于这些构建块是基于服务器的，开发者需要对他们应用和其他站点一样的安全模型。这些服务不需要客户端下载任何东西</SPAN><SPAN lang=EN-US><FONT face=Georgia>——</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">只要在浏览器中引用脚本代理即可。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">所有的</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET 2.0</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">构建块服务都是可插拔的，这使用一种通用的提供者（</SPAN><SPAN lang=EN-US><FONT face=Georgia>Provider</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">）模型可扩展模式在后台实现。微软提供的内建提供程序允许开发使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>SQL Server</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">数据库或</SPAN><SPAN lang=EN-US><FONT face=Georgia>Active Directory</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">作为存储容器，开发者也可以很容易地插接自己的提供程序。例如，你可能希望使用集群而不是数据库服务器来存放用户的配置文件，这时，你只需将你的提供程序插接进来即可——这一切都由开发者来决定。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端构建块服务</SPAN><SPAN lang=EN-US><FONT face=Georgia><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><o:p></o:p></FONT></SPAN></FONT></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">除了</SPAN><SPAN lang=EN-US><FONT face=Georgia>DHTML</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">、</SPAN><SPAN lang=EN-US><FONT face=Georgia>JScript</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>XMLHTTP</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，微软还提供了一组附加的服务来加强客户端的功能，并提供增强的体验。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">对于这样的服务，本地浏览器缓存就是一个很好的例子。当启用了本地浏览器缓存时，</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">站点就可以将内容存储到缓存中，并在需要的时候很快地取出。但浏览器并未提供向缓存中存放数据的</SPAN><SPAN lang=EN-US><FONT face=Georgia>API</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，而且象</SPAN><SPAN lang=EN-US><FONT face=Georgia>Google Map</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">或</SPAN><SPAN lang=EN-US><FONT face=Georgia>OWA</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">这样的应用程序不得不通过很多工作产生一个唯一的</SPAN><SPAN lang=EN-US><FONT face=Georgia>URL</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">，才能使浏览器缓存它。在</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中，微软提供了可编程的本地存储</SPAN><SPAN lang=EN-US><FONT face=Georgia>/</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">缓存，因此应用程序可以很方便、有效并且安全地在本地缓存数据。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">同其它应用程序的集成是检验</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">体验是否丰富的另一个新的标准。例如，当一个用户浏览一个拍卖网站并对一件商品出价时，他可能想随时知道这个拍卖什么时候结束，但他如何才能将这个事件添加到个人的日历程序中？</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">带来了一系列客户端构建块服务，当用户选择&#8220;添加到日历&#8221;时，浏览器将调用接驳点来获取日历数据，并将其传递到本地的日历程序中。此时页面上无须下载或运行任何特殊的代码或执行任何初始化动作，因此，这比</SPAN><SPAN lang=EN-US><FONT face=Georgia>ActiveX</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">要安全得多。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">下一步</SPAN><SPAN lang=EN-US><FONT face=Georgia><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><o:p></o:p></FONT></SPAN></FONT></B></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">随着我们的技术进展，还会发生很多事情。我们现在已经开始研发、开发和调试工具的下一个版本了，因此，我们将很快为这些类型的丰富</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序提供更加伟大的开发体验。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">您可能会问的一个问题是：</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">如何在</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和智能客户端上使用？</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">我们可以看到，</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">是编写丰富的、可交互的和个性化的</SPAN><SPAN lang=EN-US><FONT face=Georgia>Web</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">浏览器应用程序的最好方式，而</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">是微软的下一代表现层模型，可以在</SPAN><SPAN lang=EN-US><FONT face=Georgia>Windows</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">平台上提供最丰富的用户体验。</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">将使用最新的媒体集成功能和硬件加速设备，提供卓越的视觉体验。</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">将带来超越浏览器的体验。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p><FONT face=Georgia size=3>&nbsp;</FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">当然，当你构建</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">应用程序的时候，你依然可以重用</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">和</SPAN><SPAN lang=EN-US><FONT face=Georgia>Atlas</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">中的编程模型。例如，</SPAN><SPAN lang=EN-US><FONT face=Georgia>Avalon</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">客户端上依然可以使用</SPAN><SPAN lang=EN-US><FONT face=Georgia>ASP.NET</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: Georgia; mso-hansi-font-family: Georgia">构建块服务和客户端构建块服务。这种模型可以使你平滑地过渡到下一代应用程序。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></P><img src ="http://pwqzc.cnblogs.com/aggbug/264082.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-10-28 19:26 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/10/28/264082.html'>http://pwqzc.cnblogs.com/archive/2005/10/28/264082.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6719.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6719.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（五）：Atlas Hands-On-Lab 1,第一个实验</title><link>http://www.cnitblog.com/Johncools/articles/6718.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6718.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6718.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6718.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6718.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6718.html</trackback:ping><description><![CDATA[下了五天，终于下好了vs2005，现在可以开始<A href="http://go.microsoft.com/fwlink/?LinkId=52385" target=_new>Atlas Hands-On-Lab </A>的学习拉！<BR>首先到<A href="http://msdn.microsoft.com/asp.net/future/atlashol/default.aspx">http://msdn.microsoft.com/asp.net/future/atlashol/default.aspx</A>去下载回来个ASPNETAtlasHOL.vsi文件，<BR>然后双击他安装，不管是不是弹出什么对话框你一律选yes就是是，当然，你首先必须先安装好ASPNETAtlas.vsi文件。<BR>启动vs2005，点file---new ----web site在弹出的面板中选Asp.Net'Atlas'Hands-on Lab we....,再点ok。<BR>练习一：创建个Master页面去应用Atlas客户端脚本<BR>1,在解决方案管理器里面右击站点选添加新条目"add new item"；<BR>2,在弹出的对话框里面选<SPAN class=UIElement><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE"><FONT color=#808080><STRONG>Master Page，命名为</STRONG></FONT><FONT color=#000000><SPAN class=LiteralUserInput><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt"><EM>Default.master，</EM>然后去掉<SPAN class=UIElement><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE"><FONT color=#808080><STRONG>Place code in separate file（这样他不会生成代码后肢类文件）</STRONG>前面</FONT><FONT color=#000000>的勾。再点add<BR>3,切换到Default.master的代码试图，把里面的<FONT style="BACKGROUND-COLOR: #e6e6e6" face="Courier New" size=2> 
<P class=Code-Highlighted style="MARGIN: 0cm 0cm 0pt 36pt"><SPAN lang=EN-US></P>
<P class=Code-Highlighted style="MARGIN: 0cm 0cm 0pt 36pt" align=left><SPAN lang=EN-US>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<BR><BR>这是个xhtml声明，好象是过度期的声明</SPAN></P><SPAN lang=EN-US>
<P class=Code-Highlighted style="BACKGROUND-COLOR: #ffffff"><FONT style="BACKGROUND-COLOR: #ffffff">4,在里面去掉所有的</FONT></P></SPAN></SPAN></FONT></FONT></SPAN></SPAN></SPAN></SPAN></FONT></SPAN></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/268845.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-04 14:03 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/04/268845.html'>http://pwqzc.cnblogs.com/archive/2005/11/04/268845.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6718.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6718.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（六）：Hands-On Lab 2第二个实验，使用atlas宣告块调用web服务</title><link>http://www.cnitblog.com/Johncools/articles/6717.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6717.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6717.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6717.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6717.html</trackback:ping><description><![CDATA[如果您没有做第一个实验请您先做下，这个实验讲的是如何使用atlas宣告块来调用web服务而不要写js脚本，大家应该记得我们在第一个实验里是使用js 脚本来调用web 服务里的方法的，现在不要写了那个js脚本了，直接使用atlas宣告块来调用web services，不知道为什么，我私下认为这个方法还没有上面的那个方法（使用js脚本的方法）来的更简单。 <BR>练习一：创建一个asp.net content 页 <BR>&nbsp;&nbsp;&nbsp;&nbsp; 在实验的这个部分，你将做一个和实验1一样具有相同的结果和控件的asp.net content页。 <BR>1，创建一个content页，在解决方案管理器上个实验里我们创建的Default.master上右击，选Add Content Page.且命名为<SPAN class=LiteralUserInput><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt"><EM>HelloWorldDeclarative.aspx。 <BR>2，切换到</EM>代码视图，删除那两个ContentPlaceHolderId属性值不是Main的<?xml:namespace prefix = asp /><asp:content>元素。在&lt;%@ Page指令行，设置他的Title属性为&#8220;Atlas实验2&#8221; <BR>3，添加控件到content页面上。在<asp:content>元素里面，添加下面的一些控件标记。 <BR>&nbsp; 
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;form action=""&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;div&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Search for <o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;input id="SearchKey" type="text" /&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;input id="SearchButton" type="button" value="Search" /&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/div&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;/form&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;hr style="width: 300px" /&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;div&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;span id="Results"&gt;&lt;/span&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;/div&gt; <BR>&nbsp;<SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">在这个时候如果我们切换到设计视图，我们就会看到他的设计视图和我们在实验1里所做的那个页面一样。</SPAN></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"></SPAN></SPAN><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">练习二：创建个atlas宣告块调用web服务，在实验的这个部分，创建atlas宣告块标记，你将能够调用和实验一一样的web服务而不需要写js代码。 <BR>1，在代码视图里，在&lt;asp:content&gt;元素里面，紧跟你刚刚创建底&lt;/div&gt;标记，写如下的代码： <BR>&nbsp; <SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;script type="text/xml-script"&gt;<o:p></o:p></SPAN> 
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;page xmlns:script="http://schemas.microsoft.com/xml-script/2005"&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;references&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&nbsp;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/references&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;components&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&nbsp;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/components&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/page&gt;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;/script&gt; <BR>atlas宣告块使用了标准的xhtml&nbsp; &lt;script&gt;标记，当然他的type属性值是text/xml-script,这个属性值也是唯一确定他是不是一个atlas宣告块的标识。atlas宣告块的根元素是&lt;page&gt;，他包含了atlas宣告块里面的其他所有元素，同时他也有自己的名字空间，关于这点，大家可以看看xml和xhtml的相关资料。接下来是&lt;references&gt;元素和&lt;components&gt;元素，他们涉及到atlas宣告块的两个主要部分：哪个js脚本文件将被使用（从atlas的js脚本库），哪些界面组件被联系起来。 <BR>2，在这个例子里面，在&lt;references&gt;元素里面需要添加下面的两个js文件： <BR>&nbsp; <SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;add src="ScriptLibrary/AtlasUI.js" /&gt;<o:p></o:p></SPAN> 
<P class=Code-Highlighted><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;add src="ScriptLibrary/AtlasControls.js" /&gt; <BR>在&lt;components&gt;元素里面，添加个&lt;textbox&gt;元素，一个&lt;serviceMethod&gt;元素，一个&lt;button&gt;元素，一个&lt;label&gt;元素，代码如下： <BR>&nbsp; 
<P class=Code-Background><SPAN lang=EN-US>&lt;components&gt;</SPAN><SPAN class=Code-HighlightedChar><SPAN lang=EN-US><o:p></o:p></SPAN></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;textBox id="SearchKey" /&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;serviceMethod id="helloService" url="HelloWorldService.asmx" </SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>methodName="HelloWorld"&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;bindings&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;binding dataContext="SearchKey" dataPath="text" </SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>property="parameters" propertyKey="query" /&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/bindings&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;completed&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;invokeMethod target="resultsBinding" </SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>method="evaluateIn" /&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/completed&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;/serviceMethod&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;button targetElement="SearchButton"&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;click&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;invokeMethod target="helloService" method="invoke" /&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/click&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;/button&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;label targetElement="results"&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;bindings&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;binding id="resultsBinding" dataContext="helloService" </SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>dataPath="response.object" property="text" </SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>automatic="false" /&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/bindings&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;/label&gt;</SPAN> </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;/components&gt;</SPAN> <BR></P>
<P class=Code-Highlighted>&nbsp;atlas的UI元素被定义成&lt;components&gt;元素的子元素 <BR>使用id属性把&lt;textbox&gt;和页面上的我们在最先前写的 textbox控件联系起来了。 <BR>&lt;button&gt;标记确定页面上的哪个button按钮去调用远程的方法，<SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">targetElement="SearchButton"确定了页面上的id值是SearchButton的按钮去调用远程方法。他的&lt;click&gt;元素确定了页面上按钮的行为是单击事件。在他的<SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;invokeMethod&gt;子元素里面，他的target属性指定了我们刚刚在上面 定义的&lt;serviceMethod&gt;的id。 <BR>&lt;serviceMethod&gt;标记提供了将被调用的web 服务的url，他的文件名是：<SPAN class=LiteralUserInput><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt"><EM>HelloWorldService.asmx</EM></SPAN></SPAN></SPAN></SPAN> </P></SPAN>
<P></P>
<P></P></SPAN>
<P></P>
<P></P></SPAN>
<P></P>
<P>也就是我们在实验1里面创建的那个web 服务。&lt;serviceMethod&gt;元素也提供了将要调用的web服务的方法的名字以及关于这个方法的详细资料。在他的&lt;bindings&gt;标记里面，他指定了哪个控件的值将被当做参数提交给远程方法。在&lt;completed&gt;标记里面，指定了当远程方法完成之后将要做的事。他通过&lt;method&gt;属性指定了一个本地的atlas方法<SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">evaluateIn来得到从服务器端返回的值并且把得到的值赋给本地对象&lt;label&gt;,在这里是通过target来指定的，同时&lt;label&gt;的targetElement属性指定了和页面控件id值是results的span关联起来。在&lt;label&gt;的子元素&lt;bindings&gt;指定了如何绑定从远程方法的返回值给页面上的&lt;span&gt;元素。 <BR>好了，完成后的代码如下： <BR>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Atlas实验2" %&gt; <BR>&lt;asp:Content ID="Content3" ContentPlaceHolderID="Main" Runat="Server"&gt; <BR>&nbsp;&nbsp; &lt;form action=""&gt; <BR>&nbsp; &lt;div&gt; <BR>&nbsp;&nbsp;&nbsp; Search for <BR>&nbsp;&nbsp;&nbsp; &lt;input id="SearchKey" type="text" /&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input id="SearchButton" type="button" value="Search" /&gt; <BR>&nbsp; &lt;/div&gt; <BR>&lt;/form&gt; <BR>&lt;hr style="width: 300px" /&gt; <BR>&lt;div&gt; <BR>&nbsp; &lt;span id="Results"&gt;&lt;/span&gt; <BR>&lt;/div&gt; <BR>&lt;script type="text/xml-script"&gt; <BR>&nbsp; &lt;page xmlns:script="http://schemas.microsoft.com/xml-script/2005"&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;references&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add src="ScriptLibrary/AtlasUI.js" /&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add src="ScriptLibrary/AtlasControls.js" /&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;/references&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;components&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;textBox id="SearchKey" /&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;serviceMethod id="helloService" url="HelloWorldService.asmx" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; methodName="HelloWorld"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;bindings&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;binding dataContext="SearchKey" dataPath="text" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; property="parameters" propertyKey="query" /&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bindings&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;completed&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;invokeMethod target="resultsBinding" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; method="evaluateIn" /&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/completed&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/serviceMethod&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; &lt;button targetElement="SearchButton"&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;click&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;invokeMethod target="helloService" method="invoke" /&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;/click&gt; <BR>&nbsp; &lt;/button&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; &lt;label targetElement="results"&gt; <BR>&nbsp; &lt;bindings&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;binding id="resultsBinding" dataContext="helloService" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataPath="response.object" property="text" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; automatic="false" /&gt; <BR>&nbsp; &lt;/bindings&gt; <BR>&nbsp; &lt;/label&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp; &lt;/components&gt; <BR>&nbsp; &lt;/page&gt; <BR>&lt;/script&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;/asp:Content&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;我们现在把他设置为起师页，按F5运行下，天啊，鼠标刚刚离开那个按钮，结果就在下面显示出来拉！！！ </P></SPAN>
<P>虽然这问状搞完拉，但是心中还是郁闷的，总发觉他没有实验1的方便易懂啊~~~~~~<IMG height=20 src="http://www.cnblogs.com/Emoticons/QQ/icon18.gif" width=25 border=0></P></asp:content></asp:content></SPAN></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/270382.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-07 08:42 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/07/270382.html'>http://pwqzc.cnblogs.com/archive/2005/11/07/270382.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（七）：Hands-On Lab 3第三个实验，用Atlas创建个自动完成的textbox</title><link>http://www.cnitblog.com/Johncools/articles/6716.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6716.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6716.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6716.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6716.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6716.html</trackback:ping><description><![CDATA[<P>我做这5个实验都是一个一个来的，从一到五，没有跳跃也不敢跳跃啊！呵呵。 <BR>在这个练习里面我们将创建一个asp.net web服务从一个文本文件里面获得数据且把他返回给客户端脚本。然后这客户端脚本把这些数据呈递给一个自动完成的dropdown。 <BR>1，我们先来创建一个web 服务。在解决方案管理器俩面，右击web站点，选add new item。在弹出的对话框里面，选择web service，把他取名为<SPAN class=LiteralUserInput><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><EM>AutoCompleteService.asmx，</EM></SPAN></SPAN> 且去掉<SPAN class=UIElement><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 11.0pt; mso-font-kerning: 1.0pt"><FONT style="COLOR: #000000" color=#808080><STRONG>Place code in separate file</STRONG>前面的小勾啊，这样的话他就不会生成代码后置类文件了。 <BR>2，我们手动去给这个asmx文件添加名字空间，且添加个system的引用，当然，在这个例子中还要添加其他的几个名字空间的引用，我们还要杀掉已经存在的自动生成的HelloWorld方法及与他关联的[WebMethod]属性。这个vs2005怎么就不能够象vs2003一样自动生成名字空间么？真是很郁闷，只是我的版本是beta2的，不知道正式版会是这样么？如果不能够自动生成名字空间就太残忍拉~还要在&lt;%@ WebService指令行的class属性里写完整的包含名字空间的类名，代码如下： <BR><FONT face="Times New Roman" color=#000000 size=3>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ WebService Language="C#" Class="Samples.AspNet.AutoCompleteService" %&gt; <BR>using System; <BR>using System.IO; <BR>using System.Web; <BR>using System.Collections; <BR>using System.Collections.Generic; <BR>using System.Threading; <BR>using System.Web.Services; <BR>using System.Web.Services.Protocols; <BR>using System.Xml.Serialization;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>namespace Samples.AspNet <BR>{ <BR>&nbsp;&nbsp;&nbsp; [WebService(Namespace = "http://tempuri.org/")] <BR>&nbsp;&nbsp;&nbsp; [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] <BR>&nbsp;&nbsp;&nbsp; public class AutoCompleteService : System.Web.Services.WebService <BR>&nbsp;&nbsp;&nbsp; {</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp; } <BR>}</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;2, 在类文件里面，定义一个private的string类型的数组，语法如下：<BR><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Arial Unicode MS'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">private static string[] autoCompleteWordList = null;</SPAN><BR>我们再写个GetWordList方法，大家不要忘记在方法上面加[WebMethod]属性<BR>具体写好后的代码如下：<BR></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ WebService Language="C#" Class="Samples.AspNet.AutoCompleteService" %&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>using System;<BR>using System.IO;<BR>using System.Web;<BR>using System.Collections;<BR>using System.Collections.Generic;<BR>using System.Threading;<BR>using System.Web.Services;<BR>using System.Web.Services.Protocols;<BR>using System.Xml.Serialization;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>namespace Samples.AspNet<BR>{<BR>&nbsp; [WebService(Namespace = "http://tempuri.org/")]<BR>&nbsp; [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<BR>&nbsp; public class AutoCompleteService&nbsp; : System.Web.Services.WebService <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; private static string[] autoCompleteWordList = null;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp; [WebMethod]<BR>&nbsp;&nbsp;&nbsp; public String[] GetWordList(string prefixText, int count)<BR>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (autoCompleteWordList == null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //初始化个List泛型对象<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;String&gt; words = new List&lt;string&gt;();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //初始化个文件另FileStream对象FileMode是Open,FileAccess是Read<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileStream file = new <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileStream(Server.MapPath("~/App_Data/words.txt"), FileMode.Open, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileAccess.Read);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //初始化个StreamReader对象，用来读取文件流中的文本，这里我们可以不写上面的代码而直接让StreamReader来读取文本文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StreamReader reader = new StreamReader(file);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String word;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //循环一行一行读取文本数据<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ((word = reader.ReadLine()) != null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; words.Add(word);//把每行数据添加到泛型对象中<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file.Close();//关闭文件流<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; autoCompleteWordList = words.ToArray();//把泛型对象转换成数组<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //把得到的那个数组排序<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Array.Sort(autoCompleteWordList, new CaseInsensitiveComparer());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //从刚刚那个数组中查找传递来的前缀字符<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int index = Array.BinarySearch(autoCompleteWordList, prefixText, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new CaseInsensitiveComparer());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (index &lt; 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #ff0000">index = ~index;//这话我从来没有见过，晕死不懂<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int matchingCount;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (matchingCount = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matchingCount &lt; count &amp;&amp; index + matchingCount &lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; autoCompleteWordList.Length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matchingCount++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!autoCompleteWordList[index + <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matchingCount].StartsWith(prefixText, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringComparison.CurrentCultureIgnoreCase))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] returnValue = new string[matchingCount];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (matchingCount &gt; 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Array.Copy(autoCompleteWordList, index, returnValue, 0, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matchingCount);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return returnValue;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; }<BR>}<BR>在GetWordList方法中我们要注意几点：<BR>1，如果你想让你的web service里的方法能够被外部访问那么[WebMethod]属性是必须要有的<BR>2，GetWordList方法有两个参数，第一个参数prefixText指用户最初输入在ui里的几个字符，这是将被自动完成的文本。count参数说明将有多少个选项将会显示在UI上。<BR>3，在这个实验里面自动完成的数据来自于一个文本文件，当然，数据也能够来自于数据库以及任何数据源包括web service<BR><BR><BR>练习2：使用Atlas脚本库来创建个自动完成的文本框<BR>在这个联系里面我们将基于Default.master也就是我们以前的实验创建的master页创建一个内容content页。这个内容页类似于我们第一个实验创建的那个页面，他也包含了相同的search来call我们在第一个实验里面创建在web service里面的HelloWorld方法。你在这个实验中创建的content页面将论证一些重要的Atlas概念。他将引导你去创建一个有自动完成功能的文本框当用户在这文本框中进行输入的时候。<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Arial Unicode MS'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">Auto-completion是一个被定义在Atlas脚本库中的行为，这中行为还能够添加到任何及任意多的客户端界面元素。下面我们来创建一个content页面。<BR>右击Default.master，选add content page.把这个内容页重新命名为Autocomplete.aspx.在代码视图中杀掉那两个ContentPlaceHolderId值不是Main的&lt;asp:content&gt;元素。在&lt;%@ Page指令行设置Title属性为&#8220;第三个实验&#8221;.<BR>在&lt;asp:content&gt;标记里面添加如下代码：<BR>&nbsp; </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;form action=""&gt;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;div&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Search for <o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;input id="SearchKey" type="text" /&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;input id="SearchButton" type="button" value="Search" <o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>onclick="DoSearch()"/&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/div&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;/form&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;div id="completionList"&gt;&lt;/div&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;hr style="width: 300px" /&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;div&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;span id="Results"&gt;&lt;/span&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;/div&gt;<BR><o:p><BR>我们再写一些脚本去调用web service。在最后一个&lt;div&gt;标记后面，我们写个&lt;script&gt;来调用我们在实验里创建的那个web service。也就是HelloWorldService.asmx.<BR>&nbsp; </P>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;script type="text/javascript" src="HelloWorldService.asmx/js"&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">&lt;/script&gt;<BR>好了，我们再写一些脚本以便单击search按钮的时候能够调用上面那个web service里面的HelloWorld方法，代码如下，其实这些代码就是我们在实验里面写过的。<BR>&nbsp; </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;script type="text/javascript"&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&nbsp;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>function DoSearch()<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>var SrchElem = document.getElementById("SearchKey");<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value, <o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>OnRequestComplete);<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&nbsp;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>function OnRequestComplete(result) <o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>var RsltElem = document.getElementById("Results");<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>RsltElem.innerHTML = result;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}<BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Arial Unicode MS'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">&lt;/script&gt;<BR>好了，search按钮的功能完成了，我们现在来为自动完成文本框搞个Atlas宣告块。<BR>&nbsp; </P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;script type="text/xml-script"&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;page xmlns:script="http://schemas.microsoft.com/xml-script/2005"&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;references&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/references&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;components&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/components&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/page&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Arial Unicode MS'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">&lt;/script&gt;<BR>这些代码我们在实验2里面见过了，注意根元素是page,还有个名字空间，在&lt;references&gt;标记里面放js引用，在&lt;components&gt;标记里面放一些Atlas客户端界面组件罢了。写好的代码如下：<BR></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Atlas实验3" %&gt;<BR>&lt;asp:Content ID="Content3" ContentPlaceHolderID="Main" Runat="Server"&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; &lt;form action=""&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Search for <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="SearchKey" type="text" /&gt;&amp;nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="SearchButton" type="button" value="Search" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onclick="DoSearch()"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>&nbsp; &lt;/form&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; &lt;div id="completionList"&gt;&lt;/div&gt;<BR>&nbsp; &lt;hr style="width: 300px"/&gt;<BR>&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;span id="Results"&gt;&lt;/span&gt;<BR>&nbsp; &lt;/div&gt;<BR>&nbsp; <BR>&nbsp; &lt;script type="text/javascript" src="HelloWorldService.asmx/js"&gt;<BR>&nbsp; &lt;/script&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; &lt;script type="text/javascript"&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; function DoSearch()<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; var SrchElem = document.getElementById("SearchKey");<BR>&nbsp;&nbsp;&nbsp; Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OnRequestComplete);<BR>&nbsp; }</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; function OnRequestComplete(result) <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; var RsltElem = document.getElementById("Results");<BR>&nbsp;&nbsp;&nbsp; RsltElem.innerHTML = result;<BR>&nbsp; }</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp; &lt;/script&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; &lt;script type="text/xml-script"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;page xmlns:script="http://schemas.microsoft.com/xml-script/2005"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;references&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add src="ScriptLibrary/AtlasUI.js" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add src="ScriptLibrary/AtlasControls.js" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/references&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;components&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;textBox id="SearchKey"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;behaviors&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;autoComplete <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; completionList="completionList" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serviceURL="AutoCompleteService.asmx" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; serviceMethod="GetWordList"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; minimumPrefixLength="2" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; completionSetCount="15" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; completionInterval="500" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/behaviors&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/textBox&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/components&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/page&gt;<BR>&nbsp; &lt;/script&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&lt;/asp:Content&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>我们要注意：<BR>Atlas界面元素是被定义在&lt;components&gt;子元素里面的；Behaviors被当做UI元素的子元素。Behavior联系id是SearchKey的textbox，对于autoComplete行为，他的属性意思如下：<BR>1，<SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>completionList属性指定 一个显示自动完成数据的UI元素的id。<BR>2，</STRONG><SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>serviceURL说的就是web service。<BR>3，</STRONG><SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>serviceMethod就是我们在web service里面写的那个返回数据的方法<BR>4，</STRONG><SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>minimumPrefixLength指定当在文本框里面输入多少字符的时候才开始调用那个web service里面的方法显示数据<BR>5，</STRONG><SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>completionSetCount设置显示多少条数据<BR>6，</STRONG><SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt"><STRONG>completionInterval设置显示自动完成数据的延迟豪秒数啊<BR>有三个属性是必须的：<SPAN class=CodeItem><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">completionList</SPAN></SPAN></STRONG><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt">, <SPAN class=CodeItem><STRONG>serviceURL</STRONG></SPAN>,&nbsp;和&nbsp;<SPAN class=CodeItem><STRONG>serviceMethod<BR>好拉，现在我们运行下，效果就出来拉！！</STRONG></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></FONT></P></SPAN></SPAN></SPAN></o:p></SPAN></SPAN></FONT></FONT></FONT></SPAN></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/270482.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-07 10:07 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/07/270482.html'>http://pwqzc.cnblogs.com/archive/2005/11/07/270482.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6716.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6716.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（八）：Hands-On Lab 4第四个实验，Atlas服务器控件自动完成</title><link>http://www.cnitblog.com/Johncools/articles/6715.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6715.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6715.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6715.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6715.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6715.html</trackback:ping><description><![CDATA[我们和前面三个实验一样先创建个conten页。游击Default.master,选add content page.且命名为ServerAutocomplete.aspx.我们依然要去掉那ContentPlaceHolderID值不是Main的&lt;asp:content&gt;元素，也在&lt;%@ Page指令行写Title属性为实验4。我们在&lt;asp:content&gt;元素里面写如下代码：<BR>
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;form id="Form1" runat="server"&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;div&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;div id="content"&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;h3&gt;AutoComplete server control&lt;/h3&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;p&gt;This file contains a server-side Atlas AutoComplete.&lt;/p&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>&lt;/div&gt;</SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/div&gt;</SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;/form&gt;<BR>我们保存下页面，现在我们开始添加一个服务器控件并且设置他的自动完成属性。<BR>首先我们在&lt;form&gt;标记的后面添加个"Atlas" ScriptManager控件。如下所式：<BR>&lt;form&gt;<BR><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;atlas:ScriptManager id="AtlasPage1" runat="server" /&gt;</SPAN><BR><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;atlas:ScriptManager是一个Atlas服务器端控件,每个包含Atlas服务器控件的页面里必须有且只能够有一个ScriptManager服务器控件，他用来管理页面上的其他的Atlas服务器控件！<BR>在&lt;p&gt;标记后面，添加个atlas服务器端textbox控件。<BR><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;atlas:TextBox id="searchBox" runat="server" /&gt;<BR>注意，这是一个普通的服务器控件，他拥有普通服务器控件的属性和特性。编辑器也能够自动感知所有的atlas服务器控件。<BR>我们再设置下他的属性，当然我们也可以根据编辑器的自动感知功能写代码，也可以切换到设计视图来设置他的属性，写好的atlas服务器代码如下：<BR>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;atlas:TextBox id="searchBox" runat="server" <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>AutoCompletionServiceUrl="AutoCompleteService.asmx" <o:p></o:p></SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>AutoCompletionServiceMethod="GetWordList" /&gt;<BR>这个aspx页面完全写好的代码如下：<BR><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" MasterPageFile="~/Default.master" Title="实验4" %&gt;<BR>&lt;asp:Content ID="Content3" ContentPlaceHolderID="Main" Runat="Server"&gt;<BR>&nbsp;&nbsp; &lt;form id="Form1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;atlas:ScriptManager ID="AtlasPage1" runat=server /&gt;<BR>&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div id="content"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h3&gt;AutoComplete server control&lt;/h3&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;This file contains a server-side Atlas AutoComplete.&lt;/p&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:TextBox ID="searchBox" runat=server AutoCompletionServiceUrl="AutocompleteService.asmx" AutoCompletionServiceMethod="GetWordList" /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>&nbsp; &lt;/div&gt;<BR>&lt;/form&gt;</FONT> 
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;/asp:Content&gt;<BR></FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3></FONT>好拉<BR>我们现在把他设置成妻室页，按F5运行，看看结果吧！！&nbsp;</P></SPAN></SPAN></SPAN></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/271258.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-08 10:02 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/08/271258.html'>http://pwqzc.cnblogs.com/archive/2005/11/08/271258.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6715.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠Atlas之旅（九）：Hands-On Lab 5第五个实验，使用数据绑定和模板创建个Atlas应用程序</title><link>http://www.cnitblog.com/Johncools/articles/6714.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6714.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6714.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6714.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6714.html</trackback:ping><description><![CDATA[这是5系列实验中的最后一个拉！！ <BR>在这个实验里面我们不再使用master，而是做个普通的aspx页面。这是一个标准的aspx页面，我们不需要再在&lt;head&gt;里面包含对客户端脚本库的引用了。这样的一个优势就是使用atlas服务器控件他能够自动的添加他所必须的客户端脚本。使用atlas服务器控件是开发atlas应用程序的一个简单快速高校的方法！好了，我们现在添加个aspx页面<BR>在解决方案管理器里面，右击站点，选择add new item,在弹出的对话框里选Web Form，名字是ServerControlDemo.aspx,而且去掉<SPAN class=UIElement><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE"><FONT color=#808080><STRONG>Place code in separate file </STRONG></FONT><FONT color=#000000><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">box前面的小勾，这样他就不会生成代码后置文件拉。点add。<BR>我们杀掉自动生成的那&lt;script&gt;标记。<BR>再把自动生成的&lt;!DOCTYPE文档类型声明改成：&nbsp; 
<P class=Code-Highlighted><SPAN lang=EN-US>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" </SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<BR>这是个xhtm过渡期文档声明，他有三中的，一是过渡，二是严格，三是框架。<BR>把&lt;title&gt;里面的内容改为&#8220;实验5&#8221;，然后在&lt;head&gt;里面在&lt;title&gt;外面添加个对css文件的引用，<BR>&lt;link href="site.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;<BR>写好的代码如下：<BR><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" %&gt;</FONT> 
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <BR>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3><BR>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;<BR>&lt;head runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;实验5&lt;/title&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;link rel="stylesheet" type="text/css" href="site.css"&gt;&lt;/link&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>好拉，我们现在开始添加Atlas ScriptManager、Button、DataSource控件到页面上。<BR>首先在&lt;div&gt;标记里面添加个&lt;atlas:ScriptManager.如下：<BR><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;atlas:ScriptManager id="mgr1" runat="server" /&gt;<BR>我们在上个实验就已经说到，在一个aspx页面里面只能够而且必须有一个&lt;atlas:ScriptManager服务器控件，如果这个页面包含了其他的atlas服务器控件的话,ScriptManager是用来公里其他的所有的这个页面的atlas服务器控件的服务器atlas控件。<BR>再在&lt;atlas:ScriptManager的后面添加个Atlas服务器Button,这个按钮用他单击来得到公司和他公司的url列表。我们可以根据vs2005开发环境的代码自动感知功能来写代码也可以切换到设计视图来设置他的属性。<BR>可能我们在写代码的时候vs2005开发环境会自动给标记加上/&gt;关闭标记，这个时候我们可以这样做：<BR>在菜单，点tools（工具）===options（选项），在弹出的对话框里面点开Text Editor,再点开他下面的html，再点他下面的format，在右边去掉auto insert close tag前面的小勾就可以拉！<BR>我们现在在设计视图里面来设置这个atlas服务器按钮的属性，在他的属性面板里先设置他的Text为&#8220;得到列表&#8221;，再在属性面板里点开Click,再点出来的那个Actions右边的小图，出来个对话框，先点add，设置他的target值为DataSource1,method设置为select,再点ok，切换到代码视图是这样的代码，好难看的。<BR><FONT face="Times New Roman" color=#000000 size=3>&lt;div&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:ScriptManager id="mgr1" runat="server" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:Button ID="fillButton" runat="server" Text="得到列表"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;click&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:InvokeMethodAction Method="select" Target="DataSource1"&gt;&lt;/atlas:InvokeMethodAction&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/click&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/atlas:button&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>按钮的&lt;click&gt;指定如果在按钮上单击的时候将发生什么动作。这个和指定atlas服务器空间的行为差不多。&lt;actions&gt;标记声明当响应父事件时将要发生什么事。在这个action里面将由atlas来调用DataSource服务器控件（我们将在下面添加这个控件），target属性指定了DataSource控件的id。method属性指定了一个特别的方法来调用那个绑定DataSource的web service，在这里，得到的是全部的数据列表。<BR>我们再添加个数据源控件。我们在&lt;atlas:button&gt;后面添加个atlas数据源控件，代码如下：<BR>&lt;atlas:DataSource runat="server" ID="DataSource1" ServiceUrl="~/DataService.asmx" /&gt;<BR>在这里我们设置了这个atlas服务器数据源控件的id和serviceUrl属性。<BR>我们再使用LayoutTemplate添加个atlas服务器ListView控件。我们将使用他来绑定数据源控件并且用他来显示数据。这其实就是个服务器控件，但是他有atlas的一些属性和特性，比如不要把整个页面在客户端和服务器端来回传递。紧跟&lt;atlas:DataSource控件，我们添加个&lt;atlas:ListView控件。在属性面板中设置他的id和templateitemcontrolid,代码如下：<BR><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'">&lt;atlas:ListView runat="server" id="listView1" <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>itemtemplatecontrolid="templateItem"&gt;<o:p></o:p></SPAN></P>
<P class=Code-Highlighted><SPAN lang=EN-US style="mso-fareast-font-family: 'Arial Unicode MS'"><o:p></o:p></SPAN></P>
<P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;/atlas:ListView&gt;<BR>在他里面再写个&lt;bindings&gt;和他的子元素&lt;atlas:binding,如下：<BR>&lt;bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:Binding DataContext="DataSource1" DataPath="data" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property="data" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bindings&gt;<BR>DataContext指定了这个ListView要绑定的数据源的id。<BR>在&lt;bindings&gt;元素里面定义了两个模板，一个是LayoutTemplate模板和EmptyTemplate模板，第一个用来怎么样显示数据，第二用用来当没有数据的时候显示什么。<BR>这个页面的最后代码如下：<BR>&lt;%@ Page Language="C#" %&gt;</SPAN></P>
<P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <BR>"<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>"&gt;</SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Arial Unicode MS'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: HE; mso-bidi-font-size: 12.0pt">
<P><BR>&lt;html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>" &gt;<BR>&lt;head runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;实验5&lt;/title&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;link rel="stylesheet" type="text/css" href="site.css" /&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:ScriptManager id="mgr1" runat="server" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:Button ID="fillButton" runat="server" Text="得到列表"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;click&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:InvokeMethodAction Method="select" Target="DataSource1" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Actions&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/click&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/atlas:button&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:DataSource runat="server" ID="DataSource1" ServiceUrl="~/DataService.asmx" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:ListView ID="ListView1" runat=server ItemTemplateControlID="templateItem"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:Binding DataContext="DataSource1" DataPath="data" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property="data" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LayoutTemplate&gt;<BR>&nbsp; &lt;ul runat="server" id="templateItemParent"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;li runat="server" id="templateItem"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;strong id="Strong1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:label runat="server" id="nameLabel"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:binding DataPath="Name" Property="text" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/atlas:label&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/strong&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:hyperlink runat="server" id="companyUrl" &gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;bindings&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atlas:binding DataPath="Description" Property="text" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bindings&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/atlas:hyperlink&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/li&gt;<BR>&nbsp; &lt;/ul&gt;<BR>&lt;/LayoutTemplate&gt;<BR>&lt;emptytemplate&gt;No Data&lt;/emptytemplate&gt;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/atlas:ListView&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>按F5运行，首先显示没有数据，然后点按钮，数据就出来拉<BR>大家可以看看DataService.asmx和SampleRow.cs的代码，关于泛类型不怎么懂<BR>先看书下~~~~~~~~~~~~</SPAN></FONT></SPAN></FONT></P></SPAN></SPAN></FONT></SPAN></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/271262.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-08 10:06 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/08/271262.html'>http://pwqzc.cnblogs.com/archive/2005/11/08/271262.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6714.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>老鼠之Atlas之旅：快速入门之名字空间</title><link>http://www.cnitblog.com/Johncools/articles/6713.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6713.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6713.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6713.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6713.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6713.html</trackback:ping><description><![CDATA[Atlas的Javascript扩展：名字空间(NameSpace) <BR>名字空间使你能够把一些公共的功能性函数组合到同一个名字空间中，下面的这个例子将告诉你怎么样把Person这个类添加到名字空间Demo里头，使用的方法是:Type.registerNamespace和Type.registerClass. <BR>首先我们还是那几个实验的所做的站点内添加个页面。 <BR>我们首先添加个js文件，他的主要功能是注册个Demo名字空间和把类Person注册到名字空间Demo里去 <BR>右击站点选add new item，在弹出的对话框中选：jscript file，名字为Namespace.js. <BR>写如下代码： <BR><FONT style="COLOR: #ff0000" face="Times New Roman" color=#000000 size=3>Type.registerNamespace("Demo"); <BR>//首先注册个名字空间Demo <BR>//给名字空间添加个类 <BR>Demo.Person = function(firstName, lastName, emailAddress) { <BR>&nbsp;&nbsp;&nbsp; var _firstName = firstName; <BR>&nbsp;&nbsp;&nbsp; var _lastName = lastName; <BR>&nbsp;&nbsp;&nbsp; var _emailAddress = emailAddress; <BR>&nbsp;&nbsp;&nbsp; //类方法 <BR>&nbsp;&nbsp;&nbsp; this.getFirstName = function() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return _firstName; <BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; this.getLastName = function() { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return _lastName; <BR>&nbsp;&nbsp;&nbsp; } <BR>} <BR>//注册类 <BR>Type.registerClass('Demo.Person', null, Web.IDisposable);</FONT> <BR>在解决方案管理器里面，右击站点，选add new item,在弹出的对话框中选：web form，名字为Namespace.aspx,去掉代码后置和选择Mater页前面的小勾，点add，在Namespace.aspx的代码视图里面我们仍然是先修改xhtm文档类型声明为如下： <BR><FONT color=#0000ff>&lt;!</FONT><FONT color=#800000>DOCTYPE</FONT> html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"<FONT color=#0000ff>&gt; <BR></FONT>再去掉&lt;script runat="server"&gt;&lt;/script&gt;. <BR>修改&lt;title&gt;为名字空间Namespace. <BR>然后在&lt;/title&gt;标记后面，当然也是在&lt;head&gt;标记里面添加下面几个对atlas的js脚本库的引用： <BR><FONT color=#0000ff>&lt;</FONT><FONT color=#800000>atlas:Script</FONT> ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" <FONT color=#0000ff>/&gt;</FONT> <BR>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>&lt;</FONT><FONT color=#800000>atlas:Script</FONT> ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" <FONT color=#0000ff>/&gt;</FONT> <BR>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>&lt;</FONT><FONT color=#800000>atlas:Script</FONT> ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasRuntime.js"<FONT color=#0000ff>/&gt; <BR></FONT>在这个例子里面我们可以把form标记去掉。我们再在&lt;div&gt;标记里面放段话和一个按钮，如下： <BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">&nbsp; 在这个例子中我们将把Person这个类添加到Demo这个Namespace里&lt;br&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input type="button" value="添加类到名字空间" onclick="return ThisClick();" id="button1"/&gt; <BR></SPAN>写好的代码如下，有注释： <BR>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" %&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <BR>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; <BR>&lt;head runat="server"&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;名字空间Namespace&lt;/title&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;atlas:Script ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" /&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;atlas:Script ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" /&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;atlas:Script ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasRuntime.js"/&gt; <BR>&lt;/head&gt; <BR>&lt;body&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;div&gt; <BR>&nbsp;&nbsp;&nbsp; 在这个例子中我们将把Person这个类添加到Demo这个Namespace里&lt;br&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input id="Button1" value="把Person类添加到Demo空间" type="button" onclick="return ThisClick()" /&gt;</FONT> </P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp; &lt;/div&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript" src="Namespace.js"&gt;&lt;/script&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript" language="javascript"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function ThisClick() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //定义个Person类对象变量，有三个参数 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var testPerson = new Demo.Person('老鼠','吴旗娃师傅','pwqzc1688@google.com'); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //调用Person类的两个方法得到第一个参数和二二个参数弹出信息框 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(testPerson.getFirstName()+"是"+testPerson.getLastName()+"的徒弟！"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //再return false,当然按钮的单击事件里也return ThisClick，是为了防止在其他浏览器里面弹出js控制台 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt; <BR>&lt;/body&gt; <BR>&lt;/html&gt; <BR></FONT></P><BR>大家千万要注意， &lt;script type="text/javascript" src="Namespace.js"&gt;&lt;/script&gt; <BR>不能够写成 &lt;script type="text/javascript" src="Namespace.js" /&gt;<BR>&nbsp;不知道为什么这样写就会弹出ThisClick没有定义的js错误！<BR>还没有抓个图的，现在抓个图看下效果！是在firefox里面抓的图：<BR><BR><IMG height=248 hspace=5 src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/{18B7C2E7-D89D-4D05-8871-DC8026C1A223}%20.gif" width=558 align=baseline><img src ="http://pwqzc.cnblogs.com/aggbug/272089.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-09 10:14 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/09/272089.html'>http://pwqzc.cnblogs.com/archive/2005/11/09/272089.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6713.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6713.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Asp.Net2.0无刷新客户端回调</title><link>http://www.cnitblog.com/Johncools/articles/6712.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6712.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6712.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6712.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6712.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6712.html</trackback:ping><description><![CDATA[





<p><font size="2"><span style="font-family: arial;">Asp.Net2.0的客户端回调是一种很让人激动的方法，他能够让我们控制要提交什么数据给服务器而不用提交整个页面，同时服务器也只返回你所需要的数据而不要发回整个页面。</span></font> <br>首先我们要说一个很重要的方法：GetCallbackEventRefernce.我把我的理解写出来，可能是错误的，恳请指出，非常感谢！ <br>GetCallbackEventReference
首先实现让客户端脚本有能力传递参数给服务器端的RaiseCallbackEvent方法,然后返回RaiseCallBackEvent方法的值给你
在GetCallbackEventRefernce方法中注册的一个参数（其实也是一个你要在客户端写的脚本）。调用
GetCallbackEventRefernce你必须从客户端脚本中传递给他两个参数，一个是要传递给RaiseCallbackEvent事件的
值，一个是context. <br>他的参数意义如下： <br>第一个：实现了ICallbackEventHandler借口的页面或者服务器控件，写this代表但前页面。 <br>第二个：代表你从要从客户端传递给服务器RaiseCallbackEvent方法的值 <br>第三个：你要在客户端写的一个js函数，同时，服务器也会把计算得到的数据传递给这个函数做为 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这个函数的参数。 <br>第四个：context具体什么意思我也不太清楚 <br>GetCallbackEventRefernce发送到了客户、端的代码是这样的： <br>WebForm_DoCallback('__Page',arg,ReceiveServerData,context,null,false) <br>那么我们要怎么样做才能够从客户端调用他呢？看到了三中方法： <br>第
一种：在后台写个public
string，在Page_Load中给他赋值为：=Page.ClientScript.GetCallbackEventReference
(this, "message", "ShowServerTime",
"context");注意在这里是Page.ClientScrip,因为他会返回个ClientScriptManager,
ClientScriptManager管理所有的客户端脚本。然后在前台某个按钮的onclick事件里&lt;%=那个public后台字符串%
&gt;.做个小实验代码如下： <br>前台ServerTime.aspx:为了方便去掉好多没用的html <br>&lt;%@ page language="C#" CodeFile="ServerTime.aspx.cs" Inherits="ServerTime_aspx" %&gt; <br>&lt;html&gt; <br>&nbsp;&nbsp; &lt;head&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;title&gt;Server Time&lt;/title&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;script language="javascript"&gt; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function GetServerTime() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var message = ''; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var context = ''; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%=sCallBackFunctionInvocation%&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function ShowServerTime(timeMessage, context) { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert('现在服务器上的时间是:\n' + timeMessage); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/script&gt; <br>&nbsp;&nbsp; &lt;/head&gt; <br>&lt;body&gt; <br>&nbsp;&nbsp; &lt;form id="MainForm" runat="server"&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type="button" value="得到服务器端时间" onclick="GetServerTime();" /&gt; <br>&nbsp;&nbsp; &lt;/form&gt; <br>&lt;/body&gt; <br>&lt;/html&gt; </p>
<p><br>后台：<br>using System;<br>using System.Web.UI;</p>
<p>&nbsp;public partial class ServerTime_aspx : Page,ICallbackEventHandler<br>&nbsp;{<br>//一定要实现ICallbackEventHandler借口<br>&nbsp;&nbsp;public string sCallBackFunctionInvocation;</p>
<p>&nbsp;&nbsp;void Page_Load(object sender, System.EventArgs e)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;sCallBackFunctionInvocation
= Page.ClientScript.GetCallbackEventReference(this, "message",
"ShowServerTime", "context");<br>&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;public string RaiseCallbackEvent(string eventArgument)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;return DateTime.Now.ToString();<br>&nbsp;&nbsp;}<br>&nbsp;}<br>运行，点按钮结果如下：<br><img src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/11111.gif" border="0"><br>第二种方法：在上面的方法中我们必须要在前台绑定后台，那么如果不绑定呢？我们这样做：<br>直接把GetCallbackEventReference当做js函数中的一个实现内容，然后把这个js函数注册到客户端。<br>前台TestPage代码：<br><font color="#000000" face="Times New Roman" size="3">&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="TestPage" %&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&nbsp;&nbsp;&nbsp; &lt;title&gt;Untitled Page&lt;/title&gt;<br>&lt;script type="text/javascript"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function test()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var lb = document.getElementById("Select1");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //取的那个下拉框<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var con = lb.options[lb.selectedIndex].text;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //得到你选择的下拉框的文本再调用呢个CallTheServer,是一个由服务器端输出的js函数<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CallTheServer(con,'');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function ReceiveServerData(rValue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Results.innerHTML = rValue;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;div&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select id="Select1"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option value=1 selected="selected"&gt;老鼠徒弟&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option value=2&gt;吴旗娃师傅&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/select&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input onclick="test()" value="从服务器返回下拉框文本" type=button&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span ID="Results"&gt;&lt;/span&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</font></p>
<p><font color="#000000" face="Times New Roman" size="3">后台代码：<br></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">using System;<br>using System.Data;<br>using System.Configuration;<br>using System.Collections;<br>using System.Web;<br>using System.Web.Security;<br>using System.Web.UI;<br>using System.Web.UI.WebControls;<br>using System.Web.UI.WebControls.WebParts;<br>using System.Web.UI.HtmlControls;</font></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">public partial class TestPage : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler<br>{<br>&nbsp;&nbsp;&nbsp; protected void Page_Load(object sender, EventArgs e)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");<br>&nbsp;&nbsp;String callbackScript;<br>&nbsp;&nbsp;callbackScript = "function CallTheServer(arg,context)" +<br>&nbsp;&nbsp;&nbsp;"{ " + cbReference + "} ;";<br>&nbsp;&nbsp;Page.ClientScript.RegisterStartupScript(this.GetType(),"abcdefg",callbackScript, true);<br>&nbsp;&nbsp;//第四个参数代表是不是要自动给着脚本加上&lt;script type="text/javascript"&gt;&lt;/script&gt;标记，当然要加啊<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;public String RaiseCallbackEvent(String eventArgument)<br>&nbsp;{<br>&nbsp;&nbsp;return "你选择的是" + eventArgument;<br>&nbsp;}<br>}<br></font></font></p>
<p><font color="#000000" face="Times New Roman" size="3">下面是执行结果：<br><img src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/2222.gif" border="0"><br></font>&nbsp;<br>第三种：前面两种都是&lt;input type="button"的html控件，那么如果是服务器按钮呢？当然也可以，在后台添加服务器按钮的onclick 属性。<br>前台third.aspx代码：<br><font color="#000000" face="Times New Roman" size="3">&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="third.aspx.cs" Inherits="third" %&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&nbsp;&nbsp;&nbsp; &lt;title&gt;Untitled Page&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;div&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;select id="Select1"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option selected="selected" value=1&gt;老鼠徒弟&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option value=2&gt;吴旗娃师傅&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/select&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Button ID="Button1" runat="server" Text="这是个服务器按钮" /&gt;&lt;/div&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div id="div1" /&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function Re(ret)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
document.getElementById("div1").innerHTML = ret;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(ret);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>后台代码：<br><font color="#000000" face="Times New Roman" size="3">using System;<br>using System.Data;<br>using System.Configuration;<br>using System.Collections;<br>using System.Web;<br>using System.Web.Security;<br>using System.Web.UI;<br>using System.Web.UI.WebControls;<br>using System.Web.UI.WebControls.WebParts;<br>using System.Web.UI.HtmlControls;</font></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">public partial class third : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler<br>{<br>&nbsp;&nbsp;&nbsp; protected void Page_Load(object sender, EventArgs e)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;//第四个参数为null，因为你不可能再在js中给他传参数了<br>&nbsp;&nbsp;string
str =
Page.ClientScript.GetCallbackEventReference(this,"document.getElementById('Select1').options[document.getElementById('Select1').selectedIndex].text","Re",null);<br>&nbsp;&nbsp;//return false是为了防止提交窗体<br>&nbsp;&nbsp;Button1.Attributes.Add("onclick",str+";return false;");<br>&nbsp;&nbsp;&nbsp; }</font></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">&nbsp;#region ICallbackEventHandler Members</font></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">&nbsp;public string RaiseCallbackEvent(string eventArgument)<br>&nbsp;{<br>&nbsp;&nbsp;if (eventArgument == "老鼠徒弟")<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;return "老鼠徒弟：人生如鼠，不在仓就在厕！";<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;return "吴旗娃师傅：自信自强，乐观向上";<br>&nbsp;&nbsp;}<br>&nbsp;}</font></font></p>
<p><font color="#000000" face="Times New Roman" size="3"><font color="#000000" face="Times New Roman" size="3">&nbsp;#endregion<br>}<br>小技巧，当你写完System.Web.UI.ICallbackEventHandler后，把鼠标移上去，那么System前面会有个小图表，点他会自动写好那个RaiseCallbackEvent代码，效果如下；<br><img src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/3333.gif" border="0"><br>第三个感觉最差！</font></font></p><img src ="http://pwqzc.cnblogs.com/aggbug/273277.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-10 16:41 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/10/273277.html'>http://pwqzc.cnblogs.com/archive/2005/11/10/273277.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6712.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6712.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax.Net快速入门</title><link>http://www.cnitblog.com/Johncools/articles/6711.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6711.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6711.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6711.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6711.html</trackback:ping><description><![CDATA[<P>师傅现在的项目准备用ajax，用ajax.net实现，而不是atlas，所以我先看下ajax.net，这样的话搭师傅的顺分车学习起来就很高效拉~~，当然先要自己学习下： <BR>Ajax.Net现在的最新版本是AjaxPro5.11.4.2,下载地址是：<A href="http://www.schwarz-interactive.de/">www.schwarz-interactive.de</A> <BR>首先我们新建个项目，名字是AjaxPro,我用的是vs2005beta2版本。 <BR>右击站点名字点add reference添加对我们刚刚下载来的那个叫AjaxPro.2.dll的引用，如果你用的是vs2003，则添加对AjaxPro.dll的引用，然后我们在添加个web.config文件（很郁闷的是vs2005不再自动添加web.config文件拉），修改web.config如下： <BR>&lt;system.web&gt; <BR>&nbsp;&nbsp;&lt;httpHandlers&gt; <BR>&nbsp;&nbsp;&nbsp;&lt;add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/&gt; <BR>&nbsp;&nbsp;&lt;/httpHandlers&gt; <BR>他的意思是所有的ajaxpro/*.ashx请求都由<SPAN lang=EN-US><FONT face=宋体>Ajax.PageHandlerFactory处理，而不是由默认的<SPAN lang=EN-US style="COLOR: #000000; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">System.Web.UI.PageHandlerFactory处理程序工厂来处理。 <BR>呵呵，我们现在给Default.aspx.cs文件添加个名字空间namespace MyDemo，这里更加郁闷的是为什么vs2005beta2怎么不给你自动添加名字空间啊？和2003怎么完全不同呢？ <BR>现在我们写个AjaxMethod服务器端方法，他和普通的服务器方法唯一不同的地方就是他必须要在方法的上面添加个[AjaxPro.AjaxMethod],代码如下： <BR><FONT face="Times New Roman" color=#000000 size=3><FONT face="Times New Roman" color=#000000 size=3><SPAN style="FONT-SIZE: 10pt; COLOR: #c0c0c0"><FONT face="Times New Roman" color=#000000 size=3><FONT face="Times New Roman" color=#000000 size=3>[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public DateTime GetServerTime()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return DateTime.Now;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public int AddTwo(int firstInt, int secondInt)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return firstInt + secondInt;<BR>&nbsp;&nbsp;}</FONT></FONT> <BR></SPAN></FONT></FONT>我们还必须在Page_Load里面把这个类注册下，如下： <BR><FONT face="Times New Roman" color=#000000 size=3>protected void Page_Load(object sender, EventArgs e) <BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default)); <BR>&nbsp;&nbsp;}</FONT></SPAN></FONT></SPAN> <BR></P>
<P><SPAN lang=EN-US><FONT face=宋体><SPAN lang=EN-US style="COLOR: #000000; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'"><SPAN style="FONT-SIZE: 10pt"><SPAN lang=EN-US><FONT face=宋体><SPAN lang=EN-US style="COLOR: #000000; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Courier New'; mso-bidi-font-family: 'Courier New'">这个时候我们还必须修改aspx页面的&lt;%@Page指令行，因为我们在后台搞了个名字空间，如下：<BR>&nbsp;Inherits="MyDemo._Default"也就是要把名字空间也写上。<BR>我们再写客户端脚本来调用服务器方法。代码里有详细的注释，我想我这样的菜鸟能够理解的话对于大家来说应该能够比我还要理解的更深刻点<BR>前台Default.aspx代码：<BR></SPAN></FONT></SPAN></SPAN></P><FONT face="Times New Roman" color=#000000 size=3><SPAN style="FONT-SIZE: 10pt">
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;%@ Page Language="C#" AutoEventWireup="true"&nbsp; CodeFile="Default.aspx.cs" Inherits="MyDemo._Default" %&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;<BR>&lt;head runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;Untitled Page&lt;/title&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="Button1" type="button" value="获得服务器时间" onclick="getServerTime();" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="Text1" type="text" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="Text2" type="text" /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input id="Button2" type="button" value="得到两个文本框的和" onclick="add(document.getElementById('Text1').value,document.getElementById('Text2').value)" /&gt;&lt;/div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getServerTime()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //MyDemo._Default.GetServerTime()得到从服务器传来的数据是object，要写.value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo._Default.GetServerTime().value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function add(a,b)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //把文本框的值转换成int<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var a1 = parseInt(a);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var b1 = parseInt(b);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //第1、2参数为服务器方法所需要的参数，后面一个是如果服务器返回数据<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //客户端要处理这些数据的js函数名，他有个参数就是从服务器传来的数据<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDemo._Default.AddTwo(a1,b1,getAdd);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getAdd(rel)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //要加上.value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(rel.value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>后台Default.aspx.cs代码：<BR></P>
<P><FONT face="Times New Roman" color=#000000 size=3>using System;<BR>using System.Data;<BR>using System.Configuration;<BR>using System.Web;<BR>using System.Web.Security;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.WebControls.WebParts;<BR>using System.Web.UI.HtmlControls;<BR>namespace MyDemo<BR>{<BR>&nbsp;public partial class _Default : System.Web.UI.Page<BR>&nbsp;{<BR>&nbsp;&nbsp;protected void Page_Load(object sender, EventArgs e)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));<BR>&nbsp;&nbsp;}</FONT></P>
<P><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public DateTime GetServerTime()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return DateTime.Now;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public int AddTwo(int firstInt, int secondInt)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return firstInt + secondInt;<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}<BR>按F5运行结果如下，firefox里面测试通过：<BR></FONT></P>
<P></FONT></SPAN></FONT><FONT face="Times New Roman" color=#000000 size=3><FONT face="Times New Roman" color=#000000 size=3><IMG src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/4444.gif.JPG" border=0></FONT></P></FONT></SPAN></FONT></SPAN><img src ="http://pwqzc.cnblogs.com/aggbug/273814.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-11 11:02 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/11/273814.html'>http://pwqzc.cnblogs.com/archive/2005/11/11/273814.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax.Net之提交或返回一个Class</title><link>http://www.cnitblog.com/Johncools/articles/6710.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6710.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6710.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6710.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6710.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6710.html</trackback:ping><description><![CDATA[<P>这是根据Ajax.net作者写的Demo做的，大概意思就是能够从客户端提交个服务器端定义的类给服务器端，服务器端也能够返回个Class给客户端，我简化了作者的代码，在aspx页面中没有使用cs文件，同时把所有的服务器端方法都放到了一个cs文件中！代码中赋有注释，我发觉这个ajax框架真的很简单的，好象现在看起来他比atlas和无刷新回调都要来的简单啊 ,所有代码在ie6和firefox下通过<BR>前台ClassTest.aspx代码如下： <BR>&lt;%@ Page Language="C#"%&gt; </P>
<P>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "<A href="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</A>"&gt; <BR>&lt;script runat=server&gt; <BR>&nbsp;&nbsp;&nbsp; void Page_Load(object sender, EventArgs e) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //我们要把名字空间MyDemo下的Demo类注册下 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AjaxPro.Utility.RegisterTypeForAjax(typeof(MyDemo.Demo)); <BR>&nbsp;&nbsp;&nbsp; } <BR>&lt;/script&gt; <BR>&lt;html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>" &gt; <BR>&lt;head runat="server"&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;Untitled Page&lt;/title&gt; <BR>&lt;/head&gt; <BR>&lt;body&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;div&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="返回个类对象" onclick="getClass()" /&gt;&lt;br/&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="返回个继承类对象" onclick="getInheritedClass();" /&gt;&lt;br/&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="提交个类对象给服务器端" onclick="putClass();"/&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;/form&gt; <BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getClass() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDemo.Demo.GetMyClass(getMyClass); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getMyClass(ret) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var a = ret.value; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a.FirstName); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getInheritedClass() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDemo.Demo.GetInheritedClass(getInhClass); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getInhClass(tg) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var a = tg.value; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a.LastName+"\n"+a.gid); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function putClass() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var p = MyDemo.Demo.GetMyClass().value; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //先调用服务器端方法GetMyClass返回个MyClass对象 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p.FirstName = "老鼠是"; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //第一个参数为服务器端方法所需要的参数，第二个为接受数据处理的js函数 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyDemo.Demo.PutClass(p,putMyClass); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function putMyClass(dsf) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var a = dsf.value;//得到服务器传来的数据 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a.FirstName+"\n"+a.LastName+"的徒弟！"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt; <BR>&lt;/body&gt; <BR>&lt;/html&gt; <BR>MyClass.cs 文件代码：只有被客户端调用的方法才要在方法上面加[AjaxPro.AjaxMethod]<BR>using System;<BR>using System.Data;<BR>using System.Configuration;<BR>using System.Web;<BR>using System.Web.Security;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.WebControls.WebParts;<BR>using System.Web.UI.HtmlControls;<BR>using AjaxPro;</P>
<P>/// &lt;summary&gt;<BR>/// Summary description for MyClass<BR>/// &lt;/summary&gt;<BR>/// <BR>namespace MyDemo<BR>{<BR>&nbsp;public class MyClass<BR>&nbsp;{<BR>&nbsp;&nbsp;public MyClass()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;// TODO: Add constructor logic here<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;public string FirstName = "";<BR>&nbsp;&nbsp;public string LastName = "";<BR>&nbsp;&nbsp;public int Age = 0;<BR>&nbsp;}<BR>&nbsp;//下面这个类继承自MyClass类，他将具有和上面类一样的公共属性<BR>&nbsp;public class MyInheritedClass : MyClass<BR>&nbsp;{<BR>&nbsp;&nbsp;public double Size = 0.0;<BR>&nbsp;&nbsp;public Guid gid = Guid.Empty;<BR>&nbsp;}</P>
<P>&nbsp;public class Demo<BR>&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; public Demo(){}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public MyClass GetMyClass()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//这个方法将返回一个MyClass类的实例<BR>&nbsp;&nbsp;&nbsp;MyClass c = new MyClass();<BR>&nbsp;&nbsp;&nbsp;c.FirstName = "老鼠";<BR>&nbsp;&nbsp;&nbsp;c.LastName = "吴旗娃";<BR>&nbsp;&nbsp;&nbsp;c.Age = 30;<BR>&nbsp;&nbsp;&nbsp;return c;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;//这个方法将返回给客户端一个继承类MyInheritedClass类的实例<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public MyInheritedClass GetInheritedClass()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//初始化个MyInheritedClass类对象，因为继承，所以他也具有父类公共属性<BR>&nbsp;&nbsp;&nbsp;MyInheritedClass c = new MyInheritedClass();<BR>&nbsp;&nbsp;&nbsp;c.FirstName = "老鼠";<BR>&nbsp;&nbsp;&nbsp;c.LastName = "吴旗娃";<BR>&nbsp;&nbsp;&nbsp;c.Age = 30;<BR>&nbsp;&nbsp;&nbsp;c.Size = 4.5;<BR>&nbsp;&nbsp;&nbsp;c.gid = Guid.NewGuid();<BR>&nbsp;&nbsp;&nbsp;return c;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;//下面这个方法获得从客户端传来的数据（类对象)再返回一个类对象给客户端<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public MyClass PutClass(MyClass c)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;c.LastName = "吴旗娃师傅";<BR>&nbsp;&nbsp;&nbsp;return c;<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}<BR></P><img src ="http://pwqzc.cnblogs.com/aggbug/274005.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-11 14:07 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/11/274005.html'>http://pwqzc.cnblogs.com/archive/2005/11/11/274005.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6710.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6710.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax.Net之数据类型</title><link>http://www.cnitblog.com/Johncools/articles/6709.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6709.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6709.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6709.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6709.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6709.html</trackback:ping><description><![CDATA[<P>这个例子是按照Ajax.Net的作者的Data Type示例做的，大概意思是能够把好多的数据类型做为参数传递给服务器端的Ajax.Net方法，也能够从Ajax.Net服务器端方法返回同样的数据类型。特别是他还能够把一个客户端对象转换成为一个xml文档，作者叫他为IJavaScriptObject，代码如下，有详细注释<BR>前台DataType.aspx代码：<BR>&lt;%@ Page Language="C#" %&gt;</P>
<P>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "<A href="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</A>"&gt;</P>
<P>&lt;script runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; void Page_Load(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //把类MyDataType注册下<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AjaxPro.Utility.RegisterTypeForAjax(typeof(MyDemo.MyDataType));<BR>&nbsp;&nbsp;&nbsp; }<BR>&lt;/script&gt;</P>
<P>&lt;html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>" &gt;<BR>&lt;head runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;Untitled Page&lt;/title&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;form id="form1" runat="server"&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="测试bool类型" onclick="getBoll();"/&gt;&lt;br/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="测试int类型" onclick="getInt();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="测试double类型" onclick="getDouble();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="测试char类型" onclick="getChar();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="传int，double，float给服务器" onclick="getNumber();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="传入int数组，double数组，返回object数组" onclick="getNumbers();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="传入DateTime类型" onclick="getDateTime();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;input type=button value="传入object，返回xml" onclick="getXml();" /&gt;&lt;br /&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/div&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;script type="text/javascript"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getBoll()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //调用服务器方法返回个bool类型<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetBool(false).value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getInt()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //调用服务器方法把传递的int加10再返回来<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetInt(20).value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getDouble()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //传递个double给服务器，返回个double<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetDouble(0.01).value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getChar()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //传递个char给服务器，返回他+1后的char<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetChar('a').value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getNumber()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //传递一个int，一个double一个float给服务器，以int返回他们的和<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetNumber(3,0.5,0.8).value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getNumbers()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //传递一个int数组和一个double数组给服务器，服务器分别计算每个数组的和并且以object数组的形式返回<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var p = MyDemo.MyDataType.GetNumbers([1,8,9],[1.2,55,5.02]).value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("int数组和是："+p[0]+"\ndouble数组和是："+p[1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getDateTime()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //传递当前时间给服务器，返回现在的时间加4个小时<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //注意客户端得到现在时间是new Date()不是DateTime.Now<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(MyDemo.MyDataType.GetDateTime(new Date()).value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function getXml()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //先初始化个对象,注意Object前面的O 大写啊<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var o = new Object();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.MyArray = [1,2,3,4,5,6];//o有个属性MyArray是个数组<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.MyBool = true;//o有个属性MyBool,类型是bool<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.MyString = "我爱你！";//o有个属性MyString,类型string<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //o还有个object类型的属性,MyObject再有两个属性<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.MyObject = {"FirstName":"老鼠","LastName":"吴旗娃师傅"};<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //o还有个DateTime的属性<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o.MyDate = new Date();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //调用服务器方法把这个object传给服务器，服务器把他转换成xml再返回<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var a = MyDemo.MyDataType.GetXml(o).value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(a);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;<BR>类文件MyDataType.cs代码：<BR>using System;<BR>using System.Data;<BR>using System.Configuration;<BR>using System.Web;<BR>using System.Web.Security;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.WebControls.WebParts;<BR>using System.Web.UI.HtmlControls;<BR>using AjaxPro;<BR>using System.Xml;</P>
<P>/// &lt;summary&gt;<BR>/// Summary description for MyDataType<BR>/// &lt;/summary&gt;<BR>/// <BR>namespace MyDemo<BR>{<BR>&nbsp;public class MyDataType<BR>&nbsp;{<BR>&nbsp;&nbsp;public MyDataType()<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;// TODO: Add constructor logic here<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public bool GetBool(bool b)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;//传来true返回false，船来false，返回true<BR>&nbsp;&nbsp;&nbsp;return !b;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public int GetInt(int i)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; //把传来的int参数加10返回<BR>&nbsp;&nbsp;&nbsp;return i + 10;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public double GetDouble(double d)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; //把传来的double+0.1再返回<BR>&nbsp;&nbsp;&nbsp;return d + 0.1;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public char GetChar(char c)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //把传来的char加1返回<BR>&nbsp;&nbsp;&nbsp;return ++c;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public int GetNumber(int i, double b, float f)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; //计算他们的和以int 返回<BR>&nbsp;&nbsp;&nbsp;return (int)((double)i+b+f);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public object[] GetNumbers(int[] i, double[] d)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; //传如的参数是一个int数组和一个double数组，我们分别计算这两个数组的和，<BR>&nbsp;&nbsp;&nbsp;//然后把他们做为一个object数组的一个元素。<BR>&nbsp;&nbsp;&nbsp;object[] o = new object[2];//初始化有两个元素的object数组<BR>&nbsp;&nbsp;&nbsp;o[0] = 0;//给第一个元素赋值他将用来装传来的int数组的和<BR>&nbsp;&nbsp;&nbsp;o[1] = 0;//给第二个元素赋值他将用来装传来的double数组的和<BR>&nbsp;&nbsp;&nbsp;//遍离传来的int数组，把他的和放在object的第一个元素里面<BR>&nbsp;&nbsp;&nbsp;int i1=0;<BR>&nbsp;&nbsp;&nbsp;foreach (int a in i)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;i1 += a;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;o[0] = i1;<BR>&nbsp;&nbsp;&nbsp;//遍离double数组。<BR>&nbsp;&nbsp;&nbsp;double d1 = 0;<BR>&nbsp;&nbsp;&nbsp;foreach (double b in d)<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;d1 += b;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;o[1] = d1;<BR>&nbsp;&nbsp;&nbsp;return o;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public DateTime GetDateTime(DateTime d)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; //把传来的时间加四个小时返回<BR>&nbsp;&nbsp;&nbsp;return d.AddHours(4);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;public string GetXml(IJavaScriptObject o)<BR>&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //客户端的object对象被他搞成IJavaScriptObject类型<BR>&nbsp;&nbsp;&nbsp;//把他转换成xml dom,用JavaScriptUtil的那个方法注意要using AjaxPro<BR>&nbsp;&nbsp;&nbsp;XmlDocument xml = JavaScriptUtil.ConvertIJavaScriptObjectToXml(o);<BR>&nbsp;&nbsp;&nbsp;return xml.OuterXml;<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}<BR>运行结果如下：<BR><IMG src="http://www.cnblogs.com/images/cnblogs_com/pwqzc/5555.JPG" border=0></P><img src ="http://pwqzc.cnblogs.com/aggbug/274148.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-11 16:35 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/11/274148.html'>http://pwqzc.cnblogs.com/archive/2005/11/11/274148.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6709.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6709.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ajax.Net的onLoading及aspx页面的默认名字空间及ajaxpro的google组怎么没有一个chinese？</title><link>http://www.cnitblog.com/Johncools/articles/6708.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6708.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6708.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6708.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6708.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6708.html</trackback:ping><description><![CDATA[<P>这是ajax.net作者做的onLoading demo。下载他的代码来看，有几点疑问：<BR>1，如果一个aspx页面没有后置代码cs类文件，或者在vs2005中没有给他手动加上名字空间，那么aspx的默认的名字空间是什么呢？难道是ASP？？我想大家可能都没有注意到这个问题吧。请教吴旗娃师傅，他立即Response.Write(this.GetType().ToString())告诉我了结果，千真万确是ASP；<BR>2，如果一个类中包含了Ajax.Net方法，那么是不是从客户端调用这个类方法的时候是不是会发生个这个类的onLoading事件？而且调用开始的时候他是不是会返回个bool类型的值true给这个事件呢？调用结束再返回个false给这个onLoading事件呢？<BR>如果我的分析正确那么作者的代码就很好理解了，后面将附上作者的代码，就一个aspx文件，但是如果我的理解不正确又应该怎么样理解呢？<BR>3，在Ajax.Net的google网上论坛就这事情发了下帖子，当然我是用C文发的，地址是：<A href="http://groups.google.com/group/ajaxpro?lnk=li">http://groups.google.com/group/ajaxpro?lnk=li</A>，因为我E文太菜，借助与翻译工具稍微能够看懂有些E文文章，但是用E文发帖还是没有那个能耐，我的在google的ajax.net论坛发的帖子有10条回复，全部都是外国姥回的，我猜想我可能被嬉笑了下，为什么就没有一个国人参与注册到这个论坛呢？如果大家没有gmail的邀请函，请告诉我，我发给 大家！！<BR>作者的onloading.aspx代码如下：作者的演示地址：<BR><A href="http://www.schwarz-interactive.de/Examples/Special/onloading.aspx">http://www.schwarz-interactive.de/Examples/Special/onloading.aspx</A><BR>&lt;%@ Page language="c#" ClassName="LoadingDemo" Inherits="System.Web.UI.Page" %&gt;<BR>&lt;script runat="server" language="c#"&gt;</P>
<P>private void Page_Load(object sender, EventArgs e)<BR>{<BR>&nbsp;&nbsp;&nbsp; AjaxPro.Utility.RegisterTypeForAjax(typeof(LoadingDemo));<BR>}</P>
<P>[AjaxPro.AjaxMethod]<BR>public DateTime LongOperation()<BR>{<BR>&nbsp;&nbsp;&nbsp; System.Threading.Thread.Sleep(2000);<BR>&nbsp;&nbsp;&nbsp; return DateTime.Now;<BR>}</P>
<P><BR>&lt;/script&gt;<BR>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>"&gt;<BR>&lt;html&gt;<BR>&nbsp; &lt;head&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;title&gt;Ajax.NET - OnLoading Example&lt;/title&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;link rel="stylesheet" type="text/css" href="../../css/main.css"/&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;<BR>&nbsp; &lt;/head&gt;<BR>&nbsp; &lt;body&gt;<BR>&nbsp;<BR>&lt;form id="Form1" method="post" runat="server"&gt;&lt;/form&gt;</P>
<P>&lt;div class="content"&gt;</P>
<P>&lt;h1&gt;OnLoading Examples&lt;/h1&gt;</P>
<P>&lt;p&gt;Click &lt;a href="javascript:doTest1();void(0);"&gt;here&lt;/a&gt; to start a long operating method (2 seconds). After you have clicked on the link you should see a &lt;i&gt;Loading...&lt;/i&gt; message in the upper left corner.&lt;/p&gt;</P>
<P>&lt;/div&gt;</P>
<P>&lt;div id="loadinfo" style="visibility:hidden;position:absolute;left:0px;top:0px;background-color:Red;color:White;"&gt;Loading...&lt;/div&gt;</P>
<P>&lt;p class="footer"&gt;Last updated: November 2, 2005 by &lt;a href="<A href="http://weblogs.asp.net/mschwarz/contact.aspx">http://weblogs.asp.net/mschwarz/contact.aspx</A>" target="_blank"&gt;Michael Schwarz&lt;/a&gt;&lt;/p&gt;<BR>&lt;p&gt;&lt;a href="<A href='http://validator.w3.org/check?uri=referer"><img'>http://validator.w3.org/check?uri=referer"&gt;&lt;img</A> src="<A href="http://www.w3.org/Icons/valid-xhtml10">http://www.w3.org/Icons/valid-xhtml10</A>" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /&gt;&lt;/a&gt;&lt;/p&gt;</P>
<P>&lt;script type="text/javascript" defer="defer"&gt;</P>
<P>ASP.LoadingDemo.onLoading = function(b) {<BR>&nbsp;&nbsp;&nbsp; var l = document.getElementById("loadinfo");<BR>&nbsp;&nbsp;&nbsp; l.style.visibility = b ? "visible" : "hidden";<BR>}</P>
<P>function doTest1() {<BR>&nbsp;&nbsp;&nbsp; ASP.LoadingDemo.LongOperation(doTest1_callback);<BR>}</P>
<P>function doTest1_callback(res) {<BR>&nbsp;&nbsp;&nbsp; alert(res.value);<BR>}</P>
<P>&lt;/script&gt;<BR>&nbsp; &lt;/body&gt;<BR>&lt;/html&gt;<BR></P><img src ="http://pwqzc.cnblogs.com/aggbug/275623.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-14 08:39 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/14/275623.html'>http://pwqzc.cnblogs.com/archive/2005/11/14/275623.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6708.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6708.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CuteEditor5.0的安装及它与Ajax.net配合无刷新操作数据库!</title><link>http://www.cnitblog.com/Johncools/articles/6707.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6707.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6707.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6707.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6707.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6707.html</trackback:ping><description><![CDATA[CuteEditor真的是一款很好的web在线编辑器,但是5.0的安装和以前的版本有点不同,5.0的破解版的下载地址是:http://www.seaskyer.net,下载完后解下压缩吧,这个地球人都知道.<IMG height=20 src="http://www.cnblogs.com/Emoticons/QQ/20.gif" width=20 border=0><BR>我们在vs2005里面新建个web site吧.然后把CuteEditor添加到工具面板.我们在工具面板里面右键选择choose item,在出来的对话框里面选择browser,找到CuteEditor.dll,一路确定就可以拉.<BR>我们再添加个edit.asxp,把工具面板里面的Editor拖到页面上来.这个时候那个授权文件CuteEditor.lic应该也自动的到了bin目录下,如果没有我们必须手动烤进去.这个时候我们如果直接编译的话还是不可以的,会提示错误,因为5.0增加了个EditorImage的功能啊,所以我们必须要把CuteEditor.ImageEditor.dll和NetSpell.SpellChecker.dll(烤这个的原因是默认打开拼写检查)都烤到项目的bin目录下,同时我们也要把解压缩后的CuteSoft_Client目录全部拷贝到应用程序的根目录下.这个时候编译的时候应该没有错误了,如果还出现什么windows集成身份验证的错误,那么我们要修改IIS里面的配置,在iis的这个站点的属性里面有个目录安全性,再点身份验证和访问控制的编辑,把集成windows身份验证前面的小勾打上就是啊.<BR>上面的只是个最简单的安装,还有比如控制CueEditor的显示,已经安全性和那个什么上传的啊,还有控制用户上传的目录啊,或者给每个用户建个他们自己的图片目录啊,还必须要另外设置,如果可能我江另外写下.我们这里现在要开始用Ajax.Net来把CuteEditor的内容插入数据库拉.<BR>关于如何安装Ajax.Net,请见我的另外的一骗文章:<A style="COLOR: #ff00ff" href="/archive/2005/11/11/273814.html" target=_blank>Ajax.Net快速入门</A>.<BR>如何把CueEditor里面的内容用Ajax插入数据库呢?首先关键是获得CuteEditor的客户端ID,这个可以通过&lt;%=Editor1.ClietID%&gt;来获得.再就是如何在客户端获得Editor里面的内容.这个可以使用他的内在的JavaScript API,getHTML(),注意是HTML.下面是一个把CuteEditor的内容插入数据库的一个html按钮代码:<BR>&lt;input id="btnOk" type="button" value="确定" onclick="insertEditor();" /&gt;<BR>接着是一个js脚本:我们假设Editor的ID是Editor1<BR>&lt;script language="javascript" type="text/javascript"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;!--<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function insertEditor()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var editor = document.getElementById('&lt;%=Editor1.ClientID %&gt;');<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var editorText = editor.getHTML();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WDDHY.EditMyPage.InsertEditor(editorText,onComplete);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function onComplete(ret)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(ret.value=="OK")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("保存成功!");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert("失败!");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; //--&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt;<BR>我们再看服务器段的Ajax方法:<BR>[AjaxPro.AjaxMethod]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string InsertEditor(string insertStr)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string connStr = System.Configuration.ConfigurationManager.AppSettings["ConnString"].ToString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlConnection conn = new SqlConnection(connStr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string cmdStr = "insert into userContent(this_content,this_name) values(@content,@name)";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlCommand comm = new SqlCommand(cmdStr,conn);<BR>//2005里面给参数赋值简单多拉!!<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comm.Parameters.AddWithValue("@content", insertStr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comm.Parameters.AddWithValue("@name","pwqzc");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conn.Open();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comm.ExecuteNonQuery();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "OK";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "BAD";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finally<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conn.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>运行,我们写点 内容到CuteEditor里面,点按钮,他一下就把数据插入进去拉!!!<BR><img src ="http://pwqzc.cnblogs.com/aggbug/284207.html" width = "1" height = "1" /><br><br><div align=right>一帆(老鼠粮仓之路) 2005-11-25 09:52 </div><br>文章来源:<a href='http://pwqzc.cnblogs.com/archive/2005/11/25/284207.html'>http://pwqzc.cnblogs.com/archive/2005/11/25/284207.html</a><img src ="http://www.cnitblog.com/Johncools/aggbug/6707.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6707.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于Atlas和AjaxPro.Net的三个小问题!</title><link>http://www.cnitblog.com/Johncools/articles/6706.html</link><dc:creator>H_J_H</dc:creator><author>H_J_H</author><pubDate>Sun, 19 Feb 2006 09:59:00 GMT</pubDate><guid>http://www.cnitblog.com/Johncools/articles/6706.html</guid><wfw:comment>http://www.cnitblog.com/Johncools/comments/6706.html</wfw:comment><comments>http://www.cnitblog.com/Johncools/articles/6706.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Johncools/comments/commentRss/6706.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Johncools/services/trackbacks/6706.html</trackback:ping><description><![CDATA[<FONT size=1>第一个问题是关于AjaxPro.Net 的,一直都没有解决,可能今年都不可能解决了.<BR>问题如下:<BR>我的开发环境是vs.net2005,AjaxPro版本是最新的5.11.4.2版本,经常出现的问题是<BR>错误： syntax error<BR>源文件：</FONT><A href="http://localhost/wddhy/ajaxpro/core.ashx"><FONT size=1>http://localhost/wddhy/ajaxpro/core.ashx</FONT></A><BR><FONT size=1>行：3<BR>源代码：<BR>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "</FONT><A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><FONT size=1>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</FONT></A><FONT size=1>"&gt;<BR>再就是引用的某个名字空间没有定义:wddhy is not define<BR>但是我明明在后台RegisterTypeForAjax(this.GetType());<BR>一直未能够找到原因,写信给Ajax.net的作者,他回信是这样说的:他现在的开发环境是2003,所以当我们用2005版本的时候可能会出现问题,因为AjaxPro.2.dll的核心代码有错误,他要到下个月才升级他的版本到2005,所以要等很长的一段时间作者才能够解决这个问题,他建议我使用atlas,因为是MS的,所以兼容应该好点.呵呵<BR>我只好使用atlas,但是也出现了一个问题,是一个简单的问题,就是用js去调用asmx方法的时候同样的提示名字空间is not define!!!真的郁闷,后来到MS的atlas论坛法帖求教,两个星期没人理,可能大家都没有碰到过这样的情况吧!因为我用的是master,后来乱打乱碰倒搞好了,我在master页面里的head里这样:<BR>&lt;head runat="server"&gt;<BR>&nbsp; &lt;asp:contentplaceholder runat="server" ID="ScriptIncludes"&gt;<BR>&nbsp; &lt;atlas:script ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" <BR>&nbsp;&nbsp;&nbsp; Browser="Mozilla" /&gt;<BR>&nbsp; &lt;atlas:script ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" <BR>&nbsp;&nbsp;&nbsp; Browser="Firefox" /&gt;<BR>&nbsp; &lt;atlas:script ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" <BR>&nbsp;&nbsp;&nbsp; Browser="AppleMAC-Safari" /&gt;<BR>&nbsp; &lt;atlas:script ID="Script4" runat="server" Path="~/ScriptLibrary/AtlasCore.js" /&gt;<BR>&nbsp; &lt;atlas:script ID="Script5" runat="server" Path="~/ScriptLibrary/AtlasCompat2.js" <BR>&nbsp;&nbsp;&nbsp; Browser="AppleMAC-Safari" /&gt;<BR>&nbsp; &lt;atlas:Script ID="Script6" runat="server" Path="~/ScriptLibrary/AtlasRuntime.js"/&gt;<BR>&nbsp; &lt;atlas:Script ID="Script7" runat="server" Path="~/ScriptLibrary/Atlas.js" /&gt;<BR>&lt;/asp:contentplaceholder&gt;<BR>&lt;link href="style.css" type="text/css" rel="Stylesheet" /&gt;<BR>&lt;asp:contentplaceholder runat="server" ID="Head" /&gt;<BR>&lt;/head&gt;<BR>当你添加内容页的时候他也会添加个<BR>&lt;asp:Content ID="Content1" ContentPlaceHolderID="ScriptIncludes" Runat="Server"&gt;<BR>&lt;/asp:Content&gt;<BR>这个时候你必须把这个content全部去掉,否则你的atlas将无法工作,这个小问题害死我了<BR>第三个小问题就是是不是可以用atlas能够和ajax.net一样直接调用服务器方法得到返回值呢?<BR>比如ajax可以这样:<BR>var a = myNameSpace.myClass.myMethod(参数).value;<BR>但是在atlas里面必须<BR>myNameSpace.myClass.myMethod(参数,onComplete);<BR>再function onComplete(ret)<BR>{}<BR>把返回的值包含在onComplete的ret参数里,这样做很不方便<BR>如果我写alert(myNameSpace.myClass.myMethod(参数));得到的是个[object Object]<BR>写alert(myNameSpace.myClass.myMethod(参数).value);得到的是undefine!<BR>晕死,在Ms的atlas论坛发帖还是没有解决,不知道怎么搞了,如果只能够这样的话那太不方便啊<BR><IMG height=1 src="http://pwqzc.cnblogs.com/aggbug/297681.html" width=1><BR><BR></FONT>
<DIV align=right><FONT size=1>一帆(老鼠粮仓之路) 2005-12-15 10:37 </FONT></DIV><BR><FONT size=1>文章来源:</FONT><A href="http://pwqzc.cnblogs.com/archive/2005/12/15/297681.html"><FONT size=1>http://pwqzc.cnblogs.com/archive/2005/12/15/297681.html</FONT></A><img src ="http://www.cnitblog.com/Johncools/aggbug/6706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Johncools/" target="_blank">H_J_H</a> 2006-02-19 17:59 <a href="http://www.cnitblog.com/Johncools/articles/6706.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>