Hi,
I am writing a web application using Expression WEB and VWD2005.
Because I start creating a web page with Expression Web, my pages don't have separate behind code pages. All the scripting is done in the .aspx page.
I used few custom validation controls to determine if a certain value is already given to a field in a record already stored (say a customer sequence number, that is not the record key!).
When debugging the application with VWD2005 I noticed that the program passes twice trough the custom validation subroutines, which creates a problem to the application.
In fact, when inserting new records, because I am checking if some value is already used, in the first pass (let's say that the value is not already used), the new record is inserted, but in a second pass, checking for the same value, it finds the newly added record, giving that way an error message stated in the custom validation control!
I double checked this way of the program running twice trough the routines and even created a new very simple page with only a formviev and a custom validation control to be used during the insert process of a new record, but it actually runs that way. Is this normal or am I missing some point in the validation process?
To give more details, I use to clear the command name property of the link buttons in the formView (the insert, update and delete buttons created automatically by the formview control) and instead use the OnClick event of the buttons to have more precise control over the insert, update or delete operations, using a try... catch structure.
Here is test example of some code for the update process. The code first executes the custom validation subroutines, than the update sub and then again the custom validation subroutines!
thanks for helping
1 <script runat=server>
2
3 Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
4
5 If args.Value > #12/31/2008# Then
6 args.IsValid = False
7 End If
8
9 End Sub
10
11 Protected Sub CustomValidator2_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
12
13 If args.Value > 1000 Then
14 args.IsValid = False
15
16 End If
17 End Sub
18
19 Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
20 If Page.IsValid Then
21 Try
22
23 FormView1.UpdateItem(True)
24 Label1.Text = "Correzione inserita!"
25 Catch ex As Exception
26
27 End Try
28 End If
29
30 End Sub
31
32 </script>
33