<
form id
=
"
form1
"
runat
=
"
server
"
>
< asp:ScriptManager ID = " ScriptManager1 " runat = " server " AllowCustomErrorsRedirect = " true " >
</ asp:ScriptManager >
< asp:UpdatePanel ID = " UpdatePanel1 " runat = " server " >
< ContentTemplate >
< asp:Button ID = " Button1 " runat = " server " Text = " Button " OnClick = " Button1_Click " />
</ ContentTemplate >
</ asp:UpdatePanel >
</ form >
< asp:ScriptManager ID = " ScriptManager1 " runat = " server " AllowCustomErrorsRedirect = " true " >
</ asp:ScriptManager >
< asp:UpdatePanel ID = " UpdatePanel1 " runat = " server " >
< ContentTemplate >
< asp:Button ID = " Button1 " runat = " server " Text = " Button " OnClick = " Button1_Click " />
</ ContentTemplate >
</ asp:UpdatePanel >
</ form >
cs
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected void Button1_Click( object sender, EventArgs e)
{
throw new Exception();
}
{
}
protected void Button1_Click( object sender, EventArgs e)
{
throw new Exception();
}
在web.config中 <system.web>内加入
<
customErrors mode
=
"
On
"
defaultRedirect
=
"
~/Error.aspx
"
></
customErrors
>