Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom Validator Question [modified]

Custom Validator Question [modified]

Scheduled Pinned Locked Moved ASP.NET
helptoolsquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dayekh
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • D Dayekh

      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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • N Not Active

        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

        D Offline
        D Offline
        Dayekh
        wrote on last edited by
        #3

        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.

        D 1 Reply Last reply
        0
        • D Dayekh

          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.

          D Offline
          D Offline
          Dayekh
          wrote on last edited by
          #4

          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?

          S 1 Reply Last reply
          0
          • D Dayekh

            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?

            S Offline
            S Offline
            Sebastian T Xavier
            wrote on last edited by
            #5

            try to place a required field validator first

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups