title: Show a Client Alert After the codebehind has been processed. ASP.NET
body: <p>I have this code behind in my ASP.NET 4 Web Forms app:</p>
  
  <pre><code>Protected Sub BTNSave_Click(sender As Object, e As EventArgs) Handles BTNSave.Click
  
     If saveOnDB() Then
        showOkAlert()
     Else
        showErrorAlert()
     End If
  End Sub
  </code></pre>
  
  <p>I need to show a client alert when something done in the code behind has gone OK or an error has happened. Any idea?</p>
  
  <p>I haved tied <code>Response.Write("&lt;script&gt;alert('Successfully added');&lt;/script&gt;")</code> but this never works and even creates an error in the browser's console: "Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."</p>
  
  <p>Also I don't use <code>OnClientClick</code> because it triggers the javascript before the codebehind.</p>