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. The Lounge
  3. Annoying MVC discovery of the day

Annoying MVC discovery of the day

Scheduled Pinned Locked Moved The Lounge
asp-netarchitecturequestion
23 Posts 11 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
    realJSOP
    wrote on last edited by
    #1

    When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

    P C R R P 9 Replies Last reply
    0
    • R realJSOP

      When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      P Offline
      P Offline
      peterchen
      wrote on last edited by
      #2

      It's the first step to a natural language API. "It's true, isn't it?"

      R 1 Reply Last reply
      0
      • R realJSOP

        When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        C Offline
        C Offline
        Chris Maunder
        wrote on last edited by
        #3

        Schrödinger's Checkbox.

        cheers Chris Maunder

        R N 3 Replies Last reply
        0
        • P peterchen

          It's the first step to a natural language API. "It's true, isn't it?"

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #4

          Wouldn't that be "true,false?"? That's equally absurd so, why the f*ck not, right?

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          1 Reply Last reply
          0
          • C Chris Maunder

            Schrödinger's Checkbox.

            cheers Chris Maunder

            R Offline
            R Offline
            realJSOP
            wrote on last edited by
            #5

            This is one of the many reasons I despise web development.

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

            1 Reply Last reply
            0
            • C Chris Maunder

              Schrödinger's Checkbox.

              cheers Chris Maunder

              R Offline
              R Offline
              realJSOP
              wrote on last edited by
              #6

              It's almost as if the federal government had a hand in the implementation... It's no wonder the ObamaCare web site is so f*cked up.

              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
              -----
              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
              -----
              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

              1 Reply Last reply
              0
              • R realJSOP

                When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                R Offline
                R Offline
                Ranjan D
                wrote on last edited by
                #7

                I know it's bit wired but you are not the only one :laugh: Checkbox returning “true,false” from FormCollection. | a developer's notes - a semi-technical web development BLOG[^]

                Ranjan.D

                1 Reply Last reply
                0
                • R realJSOP

                  When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                  -----
                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                  -----
                  When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                  R Offline
                  R Offline
                  Ron Nicholson
                  wrote on last edited by
                  #8

                  Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.

                  Jack of all trades, master of none, though often times better than master of one.

                  R F G 3 Replies Last reply
                  0
                  • R Ron Nicholson

                    Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.

                    Jack of all trades, master of none, though often times better than master of one.

                    R Offline
                    R Offline
                    realJSOP
                    wrote on last edited by
                    #9

                    The only two return values I've seen in MVC are "false", and "true,false". How other bastardized Microsoft frameworks handle it are not applicable.

                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                    -----
                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                    -----
                    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                    1 Reply Last reply
                    0
                    • R Ron Nicholson

                      Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.

                      Jack of all trades, master of none, though often times better than master of one.

                      F Offline
                      F Offline
                      Foothill
                      wrote on last edited by
                      #10

                      Did I miss the announcement that they started using QBits in .Net? I guess they want to be ready for the quantum computer revolution.

                      if (Object.DividedByZero == true) { Universe.Implode(); }

                      1 Reply Last reply
                      0
                      • R Ron Nicholson

                        Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.

                        Jack of all trades, master of none, though often times better than master of one.

                        G Offline
                        G Offline
                        Gary Wheeler
                        wrote on last edited by
                        #11

                        WPF checkboxes have an IsChecked property that can be either false, true, or null. When you want to check if the checkbox is really checked, you have to:

                        if (checkbox.IsChecked == true)
                        {
                        ...
                        }

                        Butt-fugly.

                        Software Zen: delete this;

                        F R 2 Replies Last reply
                        0
                        • G Gary Wheeler

                          WPF checkboxes have an IsChecked property that can be either false, true, or null. When you want to check if the checkbox is really checked, you have to:

                          if (checkbox.IsChecked == true)
                          {
                          ...
                          }

                          Butt-fugly.

                          Software Zen: delete this;

                          F Offline
                          F Offline
                          Foothill
                          wrote on last edited by
                          #12

                          Not to get too much into a programming discussion, this is the lounge, but you can also write it this way

                          if (checkbox?.IsChecked : false)
                          {
                          //...
                          }

                          This way, if it IsChecked is null, it's still false. Leave it to Microsoft to create a system where nothing is something and you still can't divide by zero. :wtf:

                          if (Object.DividedByZero == true) { Universe.Implode(); }

                          1 Reply Last reply
                          0
                          • R realJSOP

                            When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                            -----
                            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                            -----
                            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                            P Offline
                            P Offline
                            Philippe Mori
                            wrote on last edited by
                            #13

                            As far as I know, it has (almost) nothing to do with MVC nor Microsoft. This is the data send by the form on the HTML page. If instead of accessing raw values, you would let MVC load the values in a model, then the framework would handle that kind of stuff automatically. If you want to work at low level, then you have to understand the subtilities...

                            Philippe Mori

                            R 1 Reply Last reply
                            0
                            • R realJSOP

                              When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                              -----
                              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                              -----
                              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                              Kornfeld Eliyahu PeterK Offline
                              Kornfeld Eliyahu PeterK Offline
                              Kornfeld Eliyahu Peter
                              wrote on last edited by
                              #14

                              Nothing to do with MVC...With HTML checkbox value is absolutely meaningless, you should check the 'checked' attribute... If you want to use MVC, use the helpers - they resolves the anomalies of HTML... If you want to use HTML directly...read about it...

                              Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

                              "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

                              R 1 Reply Last reply
                              0
                              • R realJSOP

                                When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                -----
                                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                -----
                                When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                N Offline
                                N Offline
                                Nish Nishant
                                wrote on last edited by
                                #15

                                It's quite weird, yes, but not an MVC or .NET specific behavior. It'd be the same if you used Ruby or JavaScript. If you use MVC's built-in model binding, they abstract this away from the coder, if not, if you really want to access it via the Form object - a recommended approach is to use GetValues(name)[0].

                                Regards, Nish


                                Website: www.voidnish.com Blog: voidnish.wordpress.com

                                R 1 Reply Last reply
                                0
                                • C Chris Maunder

                                  Schrödinger's Checkbox.

                                  cheers Chris Maunder

                                  N Offline
                                  N Offline
                                  Nish Nishant
                                  wrote on last edited by
                                  #16

                                  > John Simmons - developing bipolar checkboxes since 1989 :-)

                                  Regards, Nish


                                  Website: www.voidnish.com Blog: voidnish.wordpress.com

                                  1 Reply Last reply
                                  0
                                  • R realJSOP

                                    When you try to retrieve the value of a checkbox on a form using Request.Form.Get(keyname), the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!

                                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                    -----
                                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                    -----
                                    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                    M Offline
                                    M Offline
                                    Mark_Wallace
                                    wrote on last edited by
                                    #17

                                    It's called a "Microsoft Boolean" It has as many values as they like, and there's nothing you can do to stop them changing it to become even more useless

                                    I wanna be a eunuchs developer! Pass me a bread knife!

                                    1 Reply Last reply
                                    0
                                    • N Nish Nishant

                                      It's quite weird, yes, but not an MVC or .NET specific behavior. It'd be the same if you used Ruby or JavaScript. If you use MVC's built-in model binding, they abstract this away from the coder, if not, if you really want to access it via the Form object - a recommended approach is to use GetValues(name)[0].

                                      Regards, Nish


                                      Website: www.voidnish.com Blog: voidnish.wordpress.com

                                      R Offline
                                      R Offline
                                      realJSOP
                                      wrote on last edited by
                                      #18

                                      Did I say it was the fault of .Net or MVC?

                                      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                      -----
                                      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                      -----
                                      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                      1 Reply Last reply
                                      0
                                      • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                                        Nothing to do with MVC...With HTML checkbox value is absolutely meaningless, you should check the 'checked' attribute... If you want to use MVC, use the helpers - they resolves the anomalies of HTML... If you want to use HTML directly...read about it...

                                        Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

                                        R Offline
                                        R Offline
                                        realJSOP
                                        wrote on last edited by
                                        #19

                                        I *am* using the helpers, and this has NOTHING to do with whether I'm using them or not. I'm using the standard method for retrieving the checked status from within a view. REGARDLESS of all of that, "true,false" as a return value is severely f*cked up.

                                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                        -----
                                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                        -----
                                        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                        1 Reply Last reply
                                        0
                                        • P Philippe Mori

                                          As far as I know, it has (almost) nothing to do with MVC nor Microsoft. This is the data send by the form on the HTML page. If instead of accessing raw values, you would let MVC load the values in a model, then the framework would handle that kind of stuff automatically. If you want to work at low level, then you have to understand the subtilities...

                                          Philippe Mori

                                          R Offline
                                          R Offline
                                          realJSOP
                                          wrote on last edited by
                                          #20

                                          Does it LOOK like I don't understand the "subtleties"? Returning "true,false" to indicate that a checkedbox is checked isn't a subtlety, it's f*cked up, or if you're too sensitive to call it what it really is (or you're just playing around, and not working on a real project), it's quirky.

                                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                          -----
                                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                          -----
                                          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                          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