By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,350 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,350 IT Pros & Developers. It's quick & easy.

Checkbox.CheckedChanged has a mind of its own

P: n/a
I've got a very simple ASCX page, where once someone finishes a section and
clicks the "Next >" button, the section they just finished is disabled, and
the next section appears below it, and so on. One of the controls is a
checkbox, which, when clicked, displays a hidden panel containing controls
whose input are used for filtering query results.

If someone checks the checkbox in the first section and clicks the first
"Next >" button, the checkbox stays checked, all is well. Problem is, on
the next postback, CheckedChanged is being called again on the first
checkbox, which has definitely not been changed by the user (remember, it's
disabled)!

Viewstate is not disabled in the ASCX control or the parent ASPX page,
though I'm sure it has something to do with a hole in my page lifecycle
knowledge... any suggestions?

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net

Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I did a simple test and you are correct. When viewstate is disabled the
checkbox will keep firing.

The reason is the checkbox has no idea what its previous state is because
viewstate is disabled. So when the user postback data is processed for the
checkbox, the checkbox doesn't know what the previous state is, but it does
detect data coming in from the form, so it assumes an event must be fired. I
tried textbox and the same happens there.

- J

"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:#A**************@TK2MSFTNGP10.phx.gbl...
I've got a very simple ASCX page, where once someone finishes a section and clicks the "Next >" button, the section they just finished is disabled, and the next section appears below it, and so on. One of the controls is a
checkbox, which, when clicked, displays a hidden panel containing controls
whose input are used for filtering query results.

If someone checks the checkbox in the first section and clicks the first
"Next >" button, the checkbox stays checked, all is well. Problem is, on
the next postback, CheckedChanged is being called again on the first
checkbox, which has definitely not been changed by the user (remember, it's disabled)!

Viewstate is not disabled in the ASCX control or the parent ASPX page,
though I'm sure it has something to do with a hole in my page lifecycle
knowledge... any suggestions?

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net

Nov 18 '05 #2

P: n/a
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I did a simple test and you are correct. When viewstate is disabled the
checkbox will keep firing.

The reason is the checkbox has no idea what its previous state is because
viewstate is disabled. So when the user postback data is processed for the
checkbox, the checkbox doesn't know what the previous state is, but it does detect data coming in from the form, so it assumes an event must be fired. I tried textbox and the same happens there.

- J

"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:#A**************@TK2MSFTNGP10.phx.gbl...
I've got a very simple ASCX page, where once someone finishes a section

and
clicks the "Next >" button, the section they just finished is disabled,

and
the next section appears below it, and so on. One of the controls is a
checkbox, which, when clicked, displays a hidden panel containing controls whose input are used for filtering query results.

If someone checks the checkbox in the first section and clicks the first
"Next >" button, the checkbox stays checked, all is well. Problem is, on the next postback, CheckedChanged is being called again on the first
checkbox, which has definitely not been changed by the user (remember,

it's
disabled)!

Viewstate is not disabled in the ASCX control or the parent ASPX page,
though I'm sure it has something to do with a hole in my page lifecycle
knowledge... any suggestions?

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net


Nov 18 '05 #3

P: n/a
Oops sorry about that.

Well then I modified my simple example to use viewstate, I disabled the
checkbox after its clicked, and I no longer get the event. So it may be
something you are doing in code.

- J
"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I did a simple test and you are correct. When viewstate is disabled the
checkbox will keep firing.

The reason is the checkbox has no idea what its previous state is because
viewstate is disabled. So when the user postback data is processed for the checkbox, the checkbox doesn't know what the previous state is, but it does
detect data coming in from the form, so it assumes an event must be fired. I
tried textbox and the same happens there.

- J

"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:#A**************@TK2MSFTNGP10.phx.gbl...
I've got a very simple ASCX page, where once someone finishes a section and
clicks the "Next >" button, the section they just finished is
disabled, and
the next section appears below it, and so on. One of the controls is

a checkbox, which, when clicked, displays a hidden panel containing

controls whose input are used for filtering query results.

If someone checks the checkbox in the first section and clicks the first "Next >" button, the checkbox stays checked, all is well. Problem is, on the next postback, CheckedChanged is being called again on the first
checkbox, which has definitely not been changed by the user (remember,

it's
disabled)!

Viewstate is not disabled in the ASCX control or the parent ASPX page,
though I'm sure it has something to do with a hole in my page lifecycle knowledge... any suggestions?

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net



Nov 18 '05 #4

P: n/a
Care to eloborate or show some code on what you are doing exactly?
"NoOne" <No@Where.com> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
Oops sorry about that.

Well then I modified my simple example to use viewstate, I disabled the
checkbox after its clicked, and I no longer get the event. So it may be
something you are doing in code.

- J
"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I did a simple test and you are correct. When viewstate is disabled the checkbox will keep firing.

The reason is the checkbox has no idea what its previous state is because viewstate is disabled. So when the user postback data is processed for the checkbox, the checkbox doesn't know what the previous state is, but it does
detect data coming in from the form, so it assumes an event must be fired.
I
tried textbox and the same happens there.

- J

"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:#A**************@TK2MSFTNGP10.phx.gbl...
> I've got a very simple ASCX page, where once someone finishes a

section and
> clicks the "Next >" button, the section they just finished is disabled, and
> the next section appears below it, and so on. One of the controls is a
> checkbox, which, when clicked, displays a hidden panel containing

controls
> whose input are used for filtering query results.
>
> If someone checks the checkbox in the first section and clicks the first > "Next >" button, the checkbox stays checked, all is well. Problem
is, on
> the next postback, CheckedChanged is being called again on the first
> checkbox, which has definitely not been changed by the user

(remember, it's
> disabled)!
>
> Viewstate is not disabled in the ASCX control or the parent ASPX page, > though I'm sure it has something to do with a hole in my page

lifecycle > knowledge... any suggestions?
>
> --
> Greg Hurlman
> ghurlman*AT*squaretwo*DOT*net
> http://www.squaretwo.net
>
>
>



Nov 18 '05 #5

P: n/a
Sure... I've zipped & attached the host ASPX page, ASCX file, and their
code-behind files. In addition, I failed to mention earlier that the
control is being dynamically loaded in the host page, but I have tested it
being explicitly declared, and I get the same results.

Thanks for your help!

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
Care to eloborate or show some code on what you are doing exactly?
"NoOne" <No@Where.com> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
Oops sorry about that.

Well then I modified my simple example to use viewstate, I disabled the
checkbox after its clicked, and I no longer get the event. So it may be
something you are doing in code.

- J
"Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved on by now. :)

--
Greg Hurlman
ghurlman*AT*squaretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> I did a simple test and you are correct. When viewstate is disabled the > checkbox will keep firing.
>
> The reason is the checkbox has no idea what its previous state is

because
> viewstate is disabled. So when the user postback data is processed for
the
> checkbox, the checkbox doesn't know what the previous state is, but
it does
> detect data coming in from the form, so it assumes an event must be

fired.
I
> tried textbox and the same happens there.
>
> - J
>
> "Greg Hurlman" <ghurlman*AT*squaretwo*DOT*net> wrote in message
> news:#A**************@TK2MSFTNGP10.phx.gbl...
> > I've got a very simple ASCX page, where once someone finishes a

section
> and
> > clicks the "Next >" button, the section they just finished is

disabled,
> and
> > the next section appears below it, and so on. One of the controls

is
a
> > checkbox, which, when clicked, displays a hidden panel containing
controls
> > whose input are used for filtering query results.
> >
> > If someone checks the checkbox in the first section and clicks the

first
> > "Next >" button, the checkbox stays checked, all is well. Problem

is, on
> > the next postback, CheckedChanged is being called again on the first > > checkbox, which has definitely not been changed by the user (remember, > it's
> > disabled)!
> >
> > Viewstate is not disabled in the ASCX control or the parent ASPX page, > > though I'm sure it has something to do with a hole in my page

lifecycle
> > knowledge... any suggestions?
> >
> > --
> > Greg Hurlman
> > ghurlman*AT*squaretwo*DOT*net
> > http://www.squaretwo.net
> >
> >
> >
>
>





Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.