Dynamic CheckBox Problem
-
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~
-
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~
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
-
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~
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]
-
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]
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 fromIPostBackDataHandler
. 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, beforePage_Load
we haveLoadViewState()
andLoadPostbackData().
So, though you disable the viewstate for Checkbox, It will load the data inLoadPostbackData()
method. This is same for a text box control as well.Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips
-
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 fromIPostBackDataHandler
. 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, beforePage_Load
we haveLoadViewState()
andLoadPostbackData().
So, though you disable the viewstate for Checkbox, It will load the data inLoadPostbackData()
method. This is same for a text box control as well.Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips
Thanks! :thumbsup:
Sandeep Mewara [My latest tip/trick] [Forum guidelines]
-
Thanks! :thumbsup:
Sandeep Mewara [My latest tip/trick] [Forum guidelines]
Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips
-
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 fromIPostBackDataHandler
. 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, beforePage_Load
we haveLoadViewState()
andLoadPostbackData().
So, though you disable the viewstate for Checkbox, It will load the data inLoadPostbackData()
method. This is same for a text box control as well.Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips
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 theLoadPostbackData()
event.Cheers!! Brij Visit my Blog: http://brijbhushan.net
My latest Articles: Give it a view Data linking with jQuery**
Exploring Client Callback** -
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 fromIPostBackDataHandler
. 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, beforePage_Load
we haveLoadViewState()
andLoadPostbackData().
So, though you disable the viewstate for Checkbox, It will load the data inLoadPostbackData()
method. This is same for a text box control as well.Cheers ! Abhijit Jana | My Blog | @Twitter | Daily .Net Tips
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 implementIPostBackDataHandler
. :thumbsup: Cheers! Ankur..Go Green..
-
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 implementIPostBackDataHandler
. :thumbsup: Cheers! Ankur..Go Green..
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**