Protected Sub formview_Inserted(sender As Object, e As FormViewInsertedEventArgs)
Dim almes As String = ""
If (Not IsNothing(e.Exception)) Then
' mostro error message e resto nella pagina
almes = "alert('Si è verificato un errore tentando di inserire il cliente, verificare i dati e riprovare\!);"
e.ExceptionHandled = True
e.KeepInInsertMode = True
Else
If (e.AffectedRows > 0) Then
' mostro success message e ridirigo
almes = "alert('Inserimento del nuovo cliente " & Replace(e.Values("an_descr1").ToString, "'", "\'") & " correttamente eseguito.');window.location.href = 'rubrica.aspx';"
Else
' mostro error message e resto nella pagina
almes = "alert('Si è verificato un errore tentando di inserire il cliente, verificare i dati e riprovare\!');"
e.KeepInInsertMode = True
End If
End If
If Not Page.ClientScript.IsStartupScriptRegistered(Me.Get Type(), "AlertScript") Then
Page.ClientScript.RegisterStartupScript(Me.GetType (), "AlertScript", almes)
End If
'Page.ClientScript.RegisterClientScriptBlock(Me.Ge tType(), "MyScript", almes, True)
End Sub