易截截图软件、单文件、免安装、纯绿色、仅160KB

Ajax 错误处理

错误处理
•调用时可以提供一个额外的错误回调函数
•包括超时和服务器端抛出的异常
•超时只能设置在WebService级别
–或者设置在PageMethods对象上
–无法在每个MethodCall时指定
•Sys.Net.WebServiceError
–timedout、message、exceptionType、stackTrace属性
ErrorHandling.asmx Code:
<%@ WebService Language="C#" Class="ErrorHandling" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Threading;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class ErrorHandling : System.Web.Services.WebService
{
[WebMethod]
public int GetDivision(int a, int b)
{
return a / b;
}
[WebMethod]
public int Timeout()
{
Thread.Sleep(5000);
return 0;
}
}
3_ErrorHandling.aspx Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="3_ErrorHandling.aspx.cs" Inherits="_3_ErrorHandling" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="ErrorHandling.asmx" />
</Services>
</asp:ScriptManager>

<input type="button" value="getDivision" onclick="getDivision(5, 0)" />
<input type="button" value="timeout" onclick="timeout()" />

<mce:script language="javascript" type="text/javascript"><!--
function getDivision(a, b)
{
ErrorHandling.GetDivision(a, b, null, failedCallback);
}

function timeout()
{
ErrorHandling.set_timeout(2000);
ErrorHandling.Timeout(null


相关文档:

jquery AJAX应用

load(url[,data][,callback])------------->通常用来从WEB服务器上获取静态的数据文件
url: string类型 请求HTML页面的URL地址
data(可选): object 发送至服务器的key/value数据
callback(可选):function 请求完成时回调函数
例子:
主页面代码:
<style type="text/css">
* { margin:0; padding ......

Ajax add_beginRequest

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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=" ......

AJAX框架的经验介绍

AJAX是WEB2.0的基石,现在网上流行几种开源的AJAX框架,比如:jQuery,Mootools,Dojo,Ext JS等等。
让我们来看看选择AJAX框架的基础:
◆你的项目需求(即你需要哪些特性,例如是否要求做出精美的界面、特效或其它功能)
◆是否支持A等级的浏览器(IE, Firefox等)?
◆文档的质量:是否完善(包含教程,API,代码示例等 ......

Ajax add_pageLoaded

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for Commen ......

ajax 处理异步刷新中出现的异常

Default3.aspx Code:
<%@Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!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"& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号