All you need is a control that you can set for text and UpdatePanel if an exception occurs during postback.
If occurs during postback: Markup:
<ajax:UpdatePanel id="ErrorUpdatePanel" runat="server" UpdateMode="Coditional"> <ContentTemplate> <asp:TextBox id="ErrorTextBox" runat="server" /> </ContentTemplate> </ajax:UpdatePanel>
code:
try { do something } catch(YourException ex) { this.ErrorTextBox.Text = ex.Message; this.ErrorUpdatePanel.Update(); }
source share