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 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
                  • 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
                    realJSOP
                    wrote on last edited by
                    #21

                    Which one of you liberal pussies marked my original message as spam? Was it because I said "F*CK" instead of that gay-ass replacement phrase "elephant"?

                    ".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
                    • 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;

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

                      I use WPF pretty much every day. It falls solidly into the category of "other bastardized Microsoft frameworks". :)

                      ".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

                      G 1 Reply Last reply
                      0
                      • R realJSOP

                        I use WPF pretty much every day. It falls solidly into the category of "other bastardized Microsoft frameworks". :)

                        ".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

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

                        I disagree with your word 'bastardized'. That implies they got WPF from someone else, and then screwed it up. I think WPF is all their own. The term "sonofabitching" works in its place. :-D

                        Software Zen: delete this;

                        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