- I created a website project, added a web form default.aspx
- I added a ScriptManager in the aspx page:
<asp:ScriptManager
ID="ScriptManager1"
runat="server"
EnablePartialRendering="true"
OnAsyncPostBackError="ScriptManager1_AsyncPostBackError">
</asp:ScriptManager>
- I added an UpdatePanel in the aspx page:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="This is a label!"></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="Click Me" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
- I throw an exception in the button click event in code behind aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "You clicked the button!";
throw new ApplicationException("an error");
}
- I set the AsyncPostBackErrorMessage in ScriptManager1_AsyncPostBackError event in code behind aspx.cs:
protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
{
ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message;
}
- I browse to the page, click the button, nothing happened
- I debug the code. I see the exception was thrown, and the AsyncPostBackErrorMessage was set, then nothing happened.
What else should I do to let ajax display the alert window?
Thanks a lot.








