Atlas中新增了ErrorTemplate,在实用性上进了一大步.
也想着体验体验,但自己琢磨了半天不行, 再按在网上的一些范例试试,也不行.网上范例模板大多如下:

ErrorTemplate
<atlas:ScriptManager runat="server"
>
<ErrorTemplate>
There was an error processing your action.<br />
<span id="errorMessageLabel"></span>
<hr />
<button type="button" id="okButton">OK</button>
</ErrorTemplate>
</atlas:ScriptManager>
原本希望在
errorMessageLabel中显示错误提示信息,然后通过
okButton返回继续,可是根本不能实现.
今天早上反复试验,最后发现
errorMessageLabel,okButton的runat必须是runat="server"才能成功.
<span id="errorMessageLabel" runat="server"/>
<button type="button" id="okButton" runat="server">OK</button>
另外,
Atlas的Sys.WebForms.PageRequestManager对象中有两个有用的方法,可用在Client端.
get_pageErrorMessage() 是用于获取服务端返回的错误信息.
clearError() 清除错误信息和标志,使页面重新可用.
(被它搞死了,特此纪念.)
附例子:

Html:Default2.aspx
1
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Help_Default2" %>
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5
<html xmlns="http://www.w3.org/1999/xhtml" >
6
<head runat="server">
7
<title>无标题页</title>
8
</head>
9
<body>
10
<form id="form1" runat="server">
11
<atlas:ScriptManager ID="s1" EnablePartialRendering=true runat=server >
12
13
<ErrorTemplate>
14
<fieldset style="WIDTH: 360px;HEIGHT: 150px; text-align: center;">
15
<legend>
16
<span style="font-size:18px; color: #ff0066"><strong>
17
Error message
18
</strong></span>
19
</legend>
20
21
<div style="WIDTH: 100%;HEIGHT: 120px;text-align: center; overflow: auto;text-align: left ;">
22
<span id="errorMessageLabel" runat="server"/>
23
</div>
24
<hr />
25
<button type="button" id="okButton" runat="server">Click here to continue</button>
26
</fieldset>
27
</ErrorTemplate>
28
29
</atlas:ScriptManager>
30
<atlas:UpdatePanel ID="p1" runat="server">
31
<ContentTemplate>
32
<asp:Label ID="Label1" runat="server" Text="当前时间:"></asp:Label>
33
<asp:Label ID="LabelServertime" runat="server" Text=" " Font-Size="24pt" ForeColor="#FF0066"></asp:Label>
34
<br />
35
<asp:Button ID="Getservertime" runat="server" Text="服务器时间" OnClick="Getservertime_Click" />
36
</ContentTemplate>
37
</atlas:UpdatePanel>
38
39
<atlas:UpdateProgress runat="server" ID="up1">
40
<ProgressTemplate>
41
<div style="position: absolute; left: 0px; top: 1px; font-size: 14px; background-color: yellow; color: red;filter: alpha(opacity=90); font-weight: bold; text-transform: capitalize; font-family: Arial;">
42
Loading
43
</div>
44
</ProgressTemplate>
45
</atlas:UpdateProgress>
46
</form>
47
</body>
48
</html>

CS:Default.aspx.cs
1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
12
public partial class Help_Default2 : System.Web.UI.Page
13

{
14
protected void Page_Load(object sender, EventArgs e)
15
{
16
17
}
18
protected void Getservertime_Click(object sender, EventArgs e)
19
{
20
System.Threading.Thread.Sleep(3000);
21
LabelServertime.Text = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
22
throw new Exception("获取时间时,出现错误.");
23
24
}
25
}