我想将程序运行中产生的异常比较友好的用ajax方式告诉客户,完全是按照ASP.NET Ajax程序设计—第I卷 (http://book.csdn.net/bookfiles/326/10032613147.shtml) 的步骤进行操作,但最后我的程序不是弹出一个javaScript 对话框,而是报出了一个JavaScript运行时错误,而不能执行下去.让我“continue” 或者"Breake"cs 文件代码如下:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.btnInvokeBadMethod);
}
protected void btnInvokeBadMethod_Click(object sender, EventArgs e)
{
throw new Exception("Hey, I want to tell you the Administrator's password of this server is XXXX!"); }
asp 文件代码如下:
<%@ Page Language="C#" AutoEventWireup="true" Debug="false" CodeBehind="WebForm1.aspx.cs" Inherits="TestAajaxScriptManager.WebForm1" %><%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %><!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" AllowCustomErrorsRedirect="false" runat="server" >
</asp:ScriptManager>
<div>
<asp:Button ID="btnInvokeBadMethod" runat="server" Text="Invoke Bad Method" OnClick="btnInvokeBadMethod_Click" />
</form>
</body>
</html>
希望大家帮我看看问题出在哪里?
谢谢!
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.btnInvokeBadMethod);
}
protected void btnInvokeBadMethod_Click(object sender, EventArgs e)
{
throw new Exception("Hey, I want to tell you the Administrator's password of this server is XXXX!"); }
asp 文件代码如下:
<%@ Page Language="C#" AutoEventWireup="true" Debug="false" CodeBehind="WebForm1.aspx.cs" Inherits="TestAajaxScriptManager.WebForm1" %><%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %><!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" AllowCustomErrorsRedirect="false" runat="server" >
</asp:ScriptManager>
<div>
<asp:Button ID="btnInvokeBadMethod" runat="server" Text="Invoke Bad Method" OnClick="btnInvokeBadMethod_Click" />
</form>
</body>
</html>
希望大家帮我看看问题出在哪里?
谢谢!
我的可以看到javascript对话框
另外:楼主不应该这样学习ajax的
你要学的是使用异步参数回调方法 而不是使用ajaxpro的基本ajax控件