Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AsyncPostBackError event, alert box not showing

$
0
0
<div>I've stuck here for days. Any help is appreciated. </div> <div></div> <div>I am using ajax toolkit 3.5 and visual studio 2008. From what I read, the default behavior when an exception is thrown during partial page update is an alert window. But I couldn't get it to work.</div> <div></div> <div>When an exception is throw during partial page update, I set the AsyncPostBackErrorMessage in ScriptManager1_AsyncPostBackError event. But the alert window is not showing, nothing happened. </div> <div></div> <div>Here is what I did:</div>
  • 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. 


Viewing all articles
Browse latest Browse all 5678

Latest Images

Trending Articles



Latest Images