UpdatePanel Exception Handling

前端 未结 3 2103
遇见更好的自我
遇见更好的自我 2021-02-01 22:42

Where exceptions occur in the UpdatePanels I\'ve implemented in the ASP.NET web app I\'m building, they cause a JavaScript error on the page with some high level error output av

3条回答
  •  长情又很酷
    2021-02-01 23:00

    You can use a combination of the AsyncPostBackError event on the ScriptManager (server-side) and the EndRequest event on the PageRequestManager (client-side) to fully handle server-side errors when using the UpdatePanel.

    Here are a couple resources that should help you:

    Customizing Error Handling for ASP.NET UpdatePanel Controls

    Error Handling Customization for ASP.NET UpdatePanel

    Here's a simple example:

    // Server-side
    protected void ScriptManager1_AsyncPostBackError(object sender, 
        AsyncPostBackErrorEventArgs e)  {
        ScriptManager1.AsyncPostBackErrorMessage =
            "An error occurred during the request: " +
            e.Exception.Message; 
    }
    
    
    // Client-side
    
    

提交回复
热议问题