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. asp.net validation

asp.net validation

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netquestion
11 Posts 5 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.
  • R Offline
    R Offline
    R Thomas 0
    wrote on last edited by
    #1

    hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

    J N Y 3 Replies Last reply
    0
    • R R Thomas 0

      hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

      J Offline
      J Offline
      Jason Pyke
      wrote on last edited by
      #2

      I have just been working on a similar problem. What I have done is to disable all the RFV and when I submit (there is another condition as well) I loop through the RFVs on the form, enable them and call validate on them. This seems to work OK for my environment. I disable them all again on cancel.

      R 1 Reply Last reply
      0
      • J Jason Pyke

        I have just been working on a similar problem. What I have done is to disable all the RFV and when I submit (there is another condition as well) I loop through the RFVs on the form, enable them and call validate on them. This seems to work OK for my environment. I disable them all again on cancel.

        R Offline
        R Offline
        R Thomas 0
        wrote on last edited by
        #3

        but the event is fired before the cancel code is processed! that means the before the control goes in the code for the cancel button, the validator is alredy fired! so back to square 1!:( "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

        1 Reply Last reply
        0
        • R R Thomas 0

          hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

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

          Unless your skip button does more than just redirect the user to the next page then make it a simple html control rather than an ASP.NET server control. Otherwise you might be able use a compare validator rather than a required field validator

          R 1 Reply Last reply
          0
          • N Not Active

            Unless your skip button does more than just redirect the user to the next page then make it a simple html control rather than an ASP.NET server control. Otherwise you might be able use a compare validator rather than a required field validator

            R Offline
            R Offline
            R Thomas 0
            wrote on last edited by
            #5

            is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

            N M 2 Replies Last reply
            0
            • R R Thomas 0

              is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

              M Offline
              M Offline
              mtone
              wrote on last edited by
              #6

              If you do not want the validate to happen when a specific control is selected set CauseValidation=false on that control. This will skip the validation.

              1 Reply Last reply
              0
              • R R Thomas 0

                is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

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

                The best way to handle this is to check in the handlers for the buttons. Do you checks and validation then enable or disable the validators as needed. OnSumit(...) { if( field1 != whatever ) { RFV.Enabled = true; Page.IsValid = false; return; } }

                R 1 Reply Last reply
                0
                • N Not Active

                  The best way to handle this is to check in the handlers for the buttons. Do you checks and validation then enable or disable the validators as needed. OnSumit(...) { if( field1 != whatever ) { RFV.Enabled = true; Page.IsValid = false; return; } }

                  R Offline
                  R Offline
                  R Thomas 0
                  wrote on last edited by
                  #8

                  if i doi as you say...then it defeats the purpose of validataion doesn't it?? if i am already checking the validation myself if(field!= whatever) then why bother to use validation? might as well check myself right? pls do correct me if i am wrong... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                  N 1 Reply Last reply
                  0
                  • R R Thomas 0

                    if i doi as you say...then it defeats the purpose of validataion doesn't it?? if i am already checking the validation myself if(field!= whatever) then why bother to use validation? might as well check myself right? pls do correct me if i am wrong... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

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

                    You're pretty much asking to go beyond the normal usage of validators anyway.:rolleyes:

                    R 1 Reply Last reply
                    0
                    • N Not Active

                      You're pretty much asking to go beyond the normal usage of validators anyway.:rolleyes:

                      R Offline
                      R Offline
                      R Thomas 0
                      wrote on last edited by
                      #10

                      so would you say.. i shouldn't use validator at all and do my validation myself? "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                      1 Reply Last reply
                      0
                      • R R Thomas 0

                        hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18

                        Y Offline
                        Y Offline
                        yangchengmin
                        wrote on last edited by
                        #11

                        set the skip button CauseValidation=false :eek: I try my best!

                        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