Custom Validator Question [modified]
-
Hi, I am trying to check where user group number 7 is logged in. If they are, then a certain Field mandatory. When I click on save, this procedure is not even running. I have been trying to fix this code since December but I can't find the problem. Please let me know if you can. Here's the code: The VB Script Protected Sub CheckTimeEstimate(ByVal sender As Object, ByVal e As ServerValidateEventArgs) Dim blDeveloper As Boolean Dim objAccess As clsAccess objAccess = New clsAccess blDeveloper = objAccess.checkHasRight(System.Convert.ToInt32(Session("UserID")), "7") If blDeveloper = True Then If Len(Me.txtTimeEstimate.Text) > 0 Then e.IsValid = True Else e.IsValid = False End If End If End Sub The Validator <OnServerValidate="CheckTimeEstimate"> Ignore the double angled brackets at the start of the validator, I did that so the page will display it. -- modified at 10:41 Tuesday 9th January, 2007
-
Hi, I am trying to check where user group number 7 is logged in. If they are, then a certain Field mandatory. When I click on save, this procedure is not even running. I have been trying to fix this code since December but I can't find the problem. Please let me know if you can. Here's the code: The VB Script Protected Sub CheckTimeEstimate(ByVal sender As Object, ByVal e As ServerValidateEventArgs) Dim blDeveloper As Boolean Dim objAccess As clsAccess objAccess = New clsAccess blDeveloper = objAccess.checkHasRight(System.Convert.ToInt32(Session("UserID")), "7") If blDeveloper = True Then If Len(Me.txtTimeEstimate.Text) > 0 Then e.IsValid = True Else e.IsValid = False End If End If End Sub The Validator <OnServerValidate="CheckTimeEstimate"> Ignore the double angled brackets at the start of the validator, I did that so the page will display it. -- modified at 10:41 Tuesday 9th January, 2007
Dayekh wrote:
I have been trying to fix this code since December but I can't find the problem.
What problem are you having that you can't find? That would be helpful.
only two letters away from being an asset
-
Dayekh wrote:
I have been trying to fix this code since December but I can't find the problem.
What problem are you having that you can't find? That would be helpful.
only two letters away from being an asset
Sorry .. I modified my post after realising what you pointed out. Here's what I intend for the code to do: 1 - I logon as Developer(User Group). 2 - I attempt to store a record while 'Time Estimate' field is empty. 3 - The Subroutine fires up and checks the ID of the user. If the User is a Developer(in this case 7), the variable blDeveloper is True, and according to my code, the validator will invalidate the developer's request. The whole point is so that the 'Time Estimate' field is Mandatory for Developer User Group but is not mandatory for others. Currently, when I try to add a record, the subroutine is not even running. That is the problem.
-
Sorry .. I modified my post after realising what you pointed out. Here's what I intend for the code to do: 1 - I logon as Developer(User Group). 2 - I attempt to store a record while 'Time Estimate' field is empty. 3 - The Subroutine fires up and checks the ID of the user. If the User is a Developer(in this case 7), the variable blDeveloper is True, and according to my code, the validator will invalidate the developer's request. The whole point is so that the 'Time Estimate' field is Mandatory for Developer User Group but is not mandatory for others. Currently, when I try to add a record, the subroutine is not even running. That is the problem.
-
I think I found the problem. The validator is not attempting to validate the Textbox because the text box is empty. How can I get the validator to ignore the fact that it's empty?
try to place a required field validator first