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. General Programming
  3. C#
  4. Form Closing Validation Problem

Form Closing Validation Problem

Scheduled Pinned Locked Moved C#
help
7 Posts 4 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.
  • P Offline
    P Offline
    PriteshMalvan
    wrote on last edited by
    #1

    Hello Friends i Have 2 text box both have validation on validated event it work well but when user open form & direct press close button of form validate event fired first so , how i can prevent this validtion. :zzz:

    S J A 4 Replies Last reply
    0
    • P PriteshMalvan

      Hello Friends i Have 2 text box both have validation on validated event it work well but when user open form & direct press close button of form validate event fired first so , how i can prevent this validtion. :zzz:

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      PriteshMalvan wrote:

      both have validation on validated event

      When are you firing this event ? i think you are doing on pageload .. Fire this event on submit button click if you have

      Thanks and Regards Sandeep If you want something you never had, do something you have never done!

      J 1 Reply Last reply
      0
      • P PriteshMalvan

        Hello Friends i Have 2 text box both have validation on validated event it work well but when user open form & direct press close button of form validate event fired first so , how i can prevent this validtion. :zzz:

        J Offline
        J Offline
        Jaiprakash M Bankolli
        wrote on last edited by
        #3

        You set the causevalidation property of the close button to false and it will work for you.

        Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com My Blog Suggestions for me

        1 Reply Last reply
        0
        • S Sandeep Akhare

          PriteshMalvan wrote:

          both have validation on validated event

          When are you firing this event ? i think you are doing on pageload .. Fire this event on submit button click if you have

          Thanks and Regards Sandeep If you want something you never had, do something you have never done!

          J Offline
          J Offline
          Jaiprakash M Bankolli
          wrote on last edited by
          #4

          Sandeep it is not related to pageload event. What exactly is happening is that when the user clicks on the close since all the validators are on so it fires the validation. So to avoid this you need to use the causevalidation property of the control. Set to false and things are done for you.

          Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com My Blog Suggestions for me

          S 1 Reply Last reply
          0
          • J Jaiprakash M Bankolli

            Sandeep it is not related to pageload event. What exactly is happening is that when the user clicks on the close since all the validators are on so it fires the validation. So to avoid this you need to use the causevalidation property of the control. Set to false and things are done for you.

            Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com My Blog Suggestions for me

            S Offline
            S Offline
            Sandeep Akhare
            wrote on last edited by
            #5

            i thought that he has written some javascript validation in some event i never made CausesValidation to true that might be reason Any way Thanks for showing right path

            Thanks and Regards Sandeep If you want something you never had, do something you have never done!

            1 Reply Last reply
            0
            • P PriteshMalvan

              Hello Friends i Have 2 text box both have validation on validated event it work well but when user open form & direct press close button of form validate event fired first so , how i can prevent this validtion. :zzz:

              A Offline
              A Offline
              AFSEKI
              wrote on last edited by
              #6

              I think you are checking a null or empty value in your validation event. You should skip validation if the text is empty. Or you can add a bool _isClosing = false variable to your class and set it to true on Form.Vlosing event, then skip validation in your textboxes' validation event if _isClosing is true. Hope this helps.

              1 Reply Last reply
              0
              • P PriteshMalvan

                Hello Friends i Have 2 text box both have validation on validated event it work well but when user open form & direct press close button of form validate event fired first so , how i can prevent this validtion. :zzz:

                A Offline
                A Offline
                AFSEKI
                wrote on last edited by
                #7

                Send the piece of code. As i guess, your textboxes are empty when the use clicks close(X sign on to Form Titlebar) validation fails because you validate if the text entered in the textbox is empty or not, if empty fail the validation which vauses form to give focus to this textbox back instead of closing.

                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