lundi 16 février 2015

Show a Client Alert After the codebehind has been procesed. ASP.NET


I have this code behind in my ASP.NET 4 Web Forms app:



Protected Sub BTNSave_Click(sender As Object, e As EventArgs) Handles BTNSave.Click

If saveOnDB() Then
showOkAlert()
Else
showErrorAlert()
End If
End Sub


I need to show a client alert when something done in the code behind has gone OK or an error has happened. Any idea?


I haved tied Response.Write("<script>alert('Successfully added');</script>") 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."


Also I don't use OnClientClick because it triggers the javascript before the codebehind.





Aucun commentaire:

Enregistrer un commentaire