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. Dynamic CheckBox Problem

Dynamic CheckBox Problem

Scheduled Pinned Locked Moved ASP.NET
helpquestion
9 Posts 5 Posters 1 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.
  • B Offline
    B Offline
    buffering83
    wrote on last edited by
    #1

    I make Dynamic Checkbox. After postback, Checkbos's check property is true. But Page's CheckBox is not checkded and Text Property was changed. reference blow code, if i clicked some button, j2j2 checkbox's check property is false, but checkbox is checked and Text was changed to fail. What should i do? CheckBox j2j2 = (CheckBox)Table2.FindControl("m_adminList30"); if (j2j2.Checked == false) j2j2.Text = "fal!"; else j2j2.Text = "good"; j2j2.Checked = j2j2.Checked;

    hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~

    A S 2 Replies Last reply
    0
    • B buffering83

      I make Dynamic Checkbox. After postback, Checkbos's check property is true. But Page's CheckBox is not checkded and Text Property was changed. reference blow code, if i clicked some button, j2j2 checkbox's check property is false, but checkbox is checked and Text was changed to fail. What should i do? CheckBox j2j2 = (CheckBox)Table2.FindControl("m_adminList30"); if (j2j2.Checked == false) j2j2.Text = "fal!"; else j2j2.Text = "good"; j2j2.Checked = j2j2.Checked;

      hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      buffering83 wrote:

      make Dynamic Checkbox. After postback, Checkbos's check property is true. But Page's CheckBox is not checkded and Text Property was changed. reference blow code, if i clicked some button, j2j2 checkbox's check property is false, but checkbox is checked and Text was changed to fail.

      Not clear what do you want to meant. Do you want your checkbox to main to postback details when checked or unchecked ? While creating the checkbox did you set CheckBox.Autopostback = "true" and in which events you have created the checkboxes ?

      Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

      1 Reply Last reply
      0
      • B buffering83

        I make Dynamic Checkbox. After postback, Checkbos's check property is true. But Page's CheckBox is not checkded and Text Property was changed. reference blow code, if i clicked some button, j2j2 checkbox's check property is false, but checkbox is checked and Text was changed to fail. What should i do? CheckBox j2j2 = (CheckBox)Table2.FindControl("m_adminList30"); if (j2j2.Checked == false) j2j2.Text = "fal!"; else j2j2.Text = "good"; j2j2.Checked = j2j2.Checked;

        hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~

        S Offline
        S Offline
        Sandeep Mewara
        wrote on last edited by
        #3

        buffering83 wrote:

        I make Dynamic Checkbox.

        Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container. Since, you need to re-create your checkbox during postback it might be getting reset to nothing and hence the value & text.

        Sandeep Mewara [My latest tip/trick] [Forum guidelines]

        A 1 Reply Last reply
        0
        • S Sandeep Mewara

          buffering83 wrote:

          I make Dynamic Checkbox.

          Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container. Since, you need to re-create your checkbox during postback it might be getting reset to nothing and hence the value & text.

          Sandeep Mewara [My latest tip/trick] [Forum guidelines]

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          Sandeep Mewara wrote:

          Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container

          Sandeep, For Checkbox EnableViewState property works in some different way. CheckBoxControl Implement from IPostBackDataHandler . This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler. Because in Page Lifecyle, before Page_Load we have LoadViewState() and LoadPostbackData(). So, though you disable the viewstate for Checkbox, It will load the data in LoadPostbackData() method. This is same for a text box control as well.

          Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

          S B A 3 Replies Last reply
          0
          • A Abhijit Jana

            Sandeep Mewara wrote:

            Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container

            Sandeep, For Checkbox EnableViewState property works in some different way. CheckBoxControl Implement from IPostBackDataHandler . This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler. Because in Page Lifecyle, before Page_Load we have LoadViewState() and LoadPostbackData(). So, though you disable the viewstate for Checkbox, It will load the data in LoadPostbackData() method. This is same for a text box control as well.

            Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

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

            Thanks! :thumbsup:

            Sandeep Mewara [My latest tip/trick] [Forum guidelines]

            A 1 Reply Last reply
            0
            • S Sandeep Mewara

              Thanks! :thumbsup:

              Sandeep Mewara [My latest tip/trick] [Forum guidelines]

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              FYI Read this[^]

              Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

              1 Reply Last reply
              0
              • A Abhijit Jana

                Sandeep Mewara wrote:

                Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container

                Sandeep, For Checkbox EnableViewState property works in some different way. CheckBoxControl Implement from IPostBackDataHandler . This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler. Because in Page Lifecyle, before Page_Load we have LoadViewState() and LoadPostbackData(). So, though you disable the viewstate for Checkbox, It will load the data in LoadPostbackData() method. This is same for a text box control as well.

                Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

                B Offline
                B Offline
                Brij
                wrote on last edited by
                #7

                Good Explanation. Every input control like checkbox, radio, textbox, hidden etc... loads its data from the form collection during LoadPostbackData() event.ASP.NET implements IPostBackDataHandler on every input control and it actually uses form collection to update the control in the LoadPostbackData() event.

                Cheers!! Brij Visit my Blog: http://brijbhushan.net
                My latest Articles: Give it a view Data linking with jQuery**
                Exploring Client Callback**

                1 Reply Last reply
                0
                • A Abhijit Jana

                  Sandeep Mewara wrote:

                  Make sure you have set 'EnableViewState=True' for the checkbox control as well as it's container

                  Sandeep, For Checkbox EnableViewState property works in some different way. CheckBoxControl Implement from IPostBackDataHandler . This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler. Because in Page Lifecyle, before Page_Load we have LoadViewState() and LoadPostbackData(). So, though you disable the viewstate for Checkbox, It will load the data in LoadPostbackData() method. This is same for a text box control as well.

                  Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips

                  A Offline
                  A Offline
                  Ankur m
                  wrote on last edited by
                  #8

                  Abhijit Jana wrote:

                  This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler.

                  Just a minor change required here AJ. The value is read from the ViewState but overridden in the LoadPostbackData() method of the page life cycle for the controls which implement IPostBackDataHandler. :thumbsup: Cheers! Ankur

                  ..Go Green..

                  B 1 Reply Last reply
                  0
                  • A Ankur m

                    Abhijit Jana wrote:

                    This value is not read from view state but from Postback from and this is true for those control which implements the IPostBackEventHandler.

                    Just a minor change required here AJ. The value is read from the ViewState but overridden in the LoadPostbackData() method of the page life cycle for the controls which implement IPostBackDataHandler. :thumbsup: Cheers! Ankur

                    ..Go Green..

                    B Offline
                    B Offline
                    Brij
                    wrote on last edited by
                    #9

                    Right!! Good correction

                    Cheers!! Brij Visit my Blog: http://brijbhushan.net
                    My latest Articles: Give it a view Data linking with jQuery**
                    Exploring Client Callback**

                    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