`

《征服ASP.NET2.0AJAX》一书的读后总结(8-14章) 收藏

 
阅读更多


<!--[if !supportLists]-->第一章<!--[endif]--> 透析XMLHttpRequest的实质
<!--[if !supportLists]-->1. <!--[endif]-->xmlHttpRequest是依附于浏览器的一个组件,IE浏览器中的此组件命名为XMLHTTP,FIREFOX中的组件名称为XMLHttpRequest; XMLHTTP是一套可以在JAVAscript,VBscript,Jscript等脚本语言中,通过HTTP协议传送或者接受XML及其他数据的一套API。XMLHTTP特点(1)局部刷新(2)异步读取;

 

<!--[if !supportLists]-->2. <!--[endif]-->XMLHTTP的open()方法:

Xmlhttp.open(Method,URL,Aysc);

Method有五种类型,主要是GET和POST,其中Get是将参数追加到URL中发送,而POST是将参数串放在请求中发送。如果数据处理不改变数据的状态(比如获取数据),就用GET,如果编辑、更新数据等改变了数据,则用POST(发送大量数据)。参数尽量放在URL中,不要用在Xmlhttp.Send(参数中),因为有验证的麻烦,如果发送有汉字,可以对参数添加escape(参数)

URL:可以为网页获取、可以从xml文件获取、从本站内某个服务器页面获取;

 

<!--[if !supportLists]-->3. <!--[endif]-->Ajax返回的类型:

<!--[if !supportLists]-->(1) <!--[endif]-->ResponseText:以字符串形式返回服务器响应;

<!--[if !supportLists]-->(2) <!--[endif]-->ResponseXML:服务器的响应必须符合XML规范;

<!--[if !supportLists]-->(3) <!--[endif]-->ResponseBode:因为服务器的响应包括head,body等全部信息,所以可使用此属性只获得响应的body部分。

<!--[if !supportLists]-->4. <!--[endif]-->

 

<!--[if !supportLists]-->5. <!--[endif]-->

 

<!--[if !supportLists]-->6. <!--[endif]-->

<!--[if !supportLists]-->第二章<!--[endif]--> Dom的简要介绍
<!--[if !supportLists]-->1. <!--[endif]-->Dom处理的文档主要是HTML和XML,所以其存储方式与树结构相似;

<!--[if !supportLists]-->2. <!--[endif]-->Dom的静态方法:

GetElementById();

Var mydom = document。GetElementsByTagName(“p”);

If(document。HasChildNodes())

//获得某控件的属性值

Var myattri = mydom。getAttribute(“type”);

<!--[if !supportLists]-->3. <!--[endif]-->

<!--[if !supportLists]-->4. <!--[endif]-->HasChildNodes;GetAttribute

 

<!--[if !supportLists]-->第三章<!--[endif]-->Dom
<!--[if !supportLists]-->第四章<!--[endif]-->AJAX组件使用范例
<!--[if !supportLists]-->1、 <!--[endif]-->Dojo组件,基于纯Javascript ,所以基于Dojo的应用并不约束任何服务器端技术;

下载地址:http://www.dojotoolkit.org/

使用方法,首先在项目中添加dojo.js文件,然后在页面的添加

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>无标题页</title>

<script type="text/javascript" src="dojo.js"></script>

<script type="text/javascript">

function wipeOut(elId)

{

//调用类中wipeOut方法

dojo.lfx.wipeOut(elId, 300).play();

}

function wipeIn(elId)

{

//调用类中wipeIn方法

dojo.lfx.wipeIn(elId, 300).play();

}

</script>

</head>

<body>

<form id="form1" runat="server">

<div id="testdiv" style="border:2px solid red; width:550px">

<div>This is a test;</div>

<div>Welcome to China</div>

<div>Welcome to Peking</div>

<div>Hello</div>

<div>欢迎光临</div>

</div>

<br/>

<button type="button" onclick="wipeOut('testdiv')">隐藏</button><br/>

<button type="button" onclick="wipeIn('testdiv')">显示</button><br/>

 

</form>

</body>

</html>

<!--[if !supportLists]-->2、 <!--[endif]-->Open Rico框架使用,是开源的,地址为:http://www.openrico.org

使用方法:首先在项目中添加rico.js(实现方法)和prototype..js(定义规范)文件。然后,在页面中引用脚本

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>无标题页</title>

<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="prototype.js"></script>

<script type="text/javascript" src="rico.js"></script>

</head>

<body >

<form id="form1" runat="server">

<table>

<tr><td>

<span class="header">简单的拖拽层示例</span>

<div style="padding:5px;border:1px solid #5b5b5b;height:50px">

<div class="box" style="background:#f7a673" id="dragme">用鼠标拖动我</div>

</div>

<br/>

<table style="margin-bottom:8px" cellspacing="3" cellpadding="3">

<tr>

<td style="width: 139px">

<div id="droponme" class="simpleDropPanel" style="background:#eed773">

<div class="title">容器1</div>

</div>

</td>

<td style="width: 135px">

<div id="droponme2" class="simpleDropPanel" style="background:#ccc3de">

<div class="title">容器2</div>

</div>

</td>

</tr>

</table>

<script type="text/javascript">

dndMgr.registerDraggable( new Rico.Draggable('test-rico-dnd','dragme') );

dndMgr.registerDropZone( new Rico.Dropzone('droponme') );

dndMgr.registerDropZone( new Rico.Dropzone('droponme2') );

</script>

</td></tr></table>

</form>

</body>

</html>

<!--[if !supportLists]-->3、 <!--[endif]-->AjaxCaller框架是具有多线程安全访问的XMLHttpRequest组件,支持XMLHttpRequest对象的销毁,Response的高速缓存,脚本的调试;下载地址:http://ajaxpatterns.org/

使用方法:首先在项目中引用util.js和ajaxCaller.js文件。然后引用脚本并使用

<head runat="server">

<title>无标题页</title>

<script type="text/javascript" src="util.js"></script>

<script type="text/javascript" src="scheduling.js"></script>

<script type="text/javascript">

function OnTask()

{

//获取任务内容

var contentText =document.getElementById("Text2").value;

//获取间隔时间

var delay = document.getElementById("Text1").value;

//调用setTimeout方法实现任务的显示

setTimeout("document.getElementById('message').innerHTML='" + contentText + "'", delay);

}

</script>

</head>

<body>

<form id="form1" runat="server">

<div>

<table style="width: 603px; height: 235px">

<tr>

<td style="width: 175px">

</td>

<td style="font-weight: bold">

&nbsp;实现定时任务的AjaxCaller演示</td>

<td>

</td>

</tr>

<tr>

<td style="width: 175px">

要等待的时间</td>

<td>

<input id="Text1" type="text" /></td>

<td>

</td>

</tr>

<tr>

<td style="width: 175px">

要说的话</td>

<td>

<input id="Text2" type="text" /></td>

<td>

</td>

</tr>

<tr>

<td style="width: 175px">

</td>

<td>

<input id="Button1" style="font-weight: bold; width: 150px" type="button" value="执行任务" onclick="OnTask()" /></td>

<td>

</td>

</tr>

<tr>

<td style="width: 175px">

</td>

<td>

<div id="message" style="width: 402px; height: 100px">

</div>

</td>

<td>

</td>

</tr>

</table>

 

</div>

</form>

</body>

<!--[if !supportLists]-->4、 <!--[endif]-->Microsoft Ajax框架:

<!--[if !supportLists]-->5、 <!--[endif]-->在工具箱中添加组件库步骤:(1)在vs2005中新建选择卡,命名为Ajax preview (2)在此选项卡右击,弹出的快捷菜单中单击“选项项”菜单命令,打开“选择工具箱项”对话框,单击“浏览”按钮,切换到“打开文件”对话框,找到CTP组件所在的DLL组件。

<!--[if !supportLists]-->6、 <!--[endif]-->

<!--[if !supportLists]-->7、 <!--[endif]-->

<!--[if !supportLists]-->第五章<!--[endif]-->使用Ajax+Asp.net2.0开发RSS阅读器
<!--[if !supportLists]-->第六章<!--[endif]-->使用Ajax+Asp.net2.0开发论坛
<!--[if !supportLists]-->第七章<!--[endif]-->Microsoft ASP.NET Ajax介绍
Asp.net 2.0 Ajax

AJAX 核心组件(ASPAJAXExtSetup.msi)

应用Miscrosoft Ajax

的基础(必须的)

下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyId=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en


ajaxControlToolkit工具(个性化组件),下载地址:

http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488

Ajax CTP 增值组件(包括WebPart的功能,还没有测试通过将来可能到AJAX中去) ,下载地址:

http://www.microsoft.com/downloads/thankyou.aspx?familyId=4cb52ea3-9548-4064-8137-09b96af97617&displayLang=en

Ajax 示例代码(学习AJAX好例子),下载地址:

http://www.asp.net/ajax/downloads/archive/

Ajax Library 类库(主要为了使用非Windows操作系统的用户,包含ASP.NET2.0 AJAX中的所有脚本组件,下载地址:

http://www.asp.net/ajax/downloads/archive/


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhang_xiao_qing_c_s_/archive/2009/02/10/3874057.aspx

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics