Avonelle's Tech Blog

Go Back

BLD Server-side Validation Difficulties

Sometimes with BLD it will appear that a server-side validation rule isn’t working. Actually the record isn’t getting inserted/updated, but the validation error doesn’t appear. For the types of pages I build, this usually means that the user is returned to a list page, but it can also manifest itself in other ways. This is very confusing.

The actual cause is that I’m using the BLDFormView_ItemInserted or BLDFormView_ItemUpdated events to identify what the system should do after the data is inserted or updated. And this code will be executed even if the record isn’t really inserted or updated. Like I said: confusing.

The solution is that within that event, you can test for an exception. Here’s some example code:

Private Sub fvQuestion_ItemInserted(sender As Object, e As FormViewInsertedEventArgs) Handles fvQuestion.ItemInserted
    'Need to check for survey side exceptions, or it will automatically execute even though no record was inserted
    If e.Exception Is Nothing Then
      'What should happen if successful…
    End If
  End Sub

So this event should always be checking for exceptions if you are using it.

Other potential causes of validation problems are Ajax (so try turning it off) and validation groups.

Posted by Avonelle on Saturday, January 26, 2013.

Facebook Twitter