473,765 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox.Checke dChanged has a mind of its own

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*squ aretwo*DOT*net
http://www.squaretwo.net

Nov 18 '05 #1
5 3129
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*sq uaretwo*DOT*net > wrote in message
news:#A******** ******@TK2MSFTN GP10.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*squ aretwo*DOT*net
http://www.squaretwo.net

Nov 18 '05 #2
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squ aretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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*sq uaretwo*DOT*net > wrote in message
news:#A******** ******@TK2MSFTN GP10.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*squ aretwo*DOT*net
http://www.squaretwo.net


Nov 18 '05 #3
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*sq uaretwo*DOT*net > wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squ aretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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*sq uaretwo*DOT*net > wrote in message
news:#A******** ******@TK2MSFTN GP10.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*squ aretwo*DOT*net
http://www.squaretwo.net



Nov 18 '05 #4
Care to eloborate or show some code on what you are doing exactly?
"NoOne" <No@Where.com > wrote in message
news:ui******** ******@tk2msftn gp13.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*sq uaretwo*DOT*net > wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved
on by now. :)

--
Greg Hurlman
ghurlman*AT*squ aretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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*sq uaretwo*DOT*net > wrote in message
news:#A******** ******@TK2MSFTN GP10.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*squ aretwo*DOT*net
> http://www.squaretwo.net
>
>
>



Nov 18 '05 #5
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*squ aretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com > wrote in message
news:e2******** ******@tk2msftn gp13.phx.gbl...
Care to eloborate or show some code on what you are doing exactly?
"NoOne" <No@Where.com > wrote in message
news:ui******** ******@tk2msftn gp13.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*sq uaretwo*DOT*net > wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
You misread... ViewState is *not* disabled... if it were, I would've moved on by now. :)

--
Greg Hurlman
ghurlman*AT*squ aretwo*DOT*net
http://www.squaretwo.net
"NoOne" <No@Where.com > wrote in message
news:%2******** ********@TK2MSF TNGP12.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*sq uaretwo*DOT*net > wrote in message
> news:#A******** ******@TK2MSFTN GP10.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*squ aretwo*DOT*net
> > http://www.squaretwo.net
> >
> >
> >
>
>





Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2338
by: Tomas Vera | last post by:
Hello All, I'm having problems creating a page with dynamic checkboxes in a WebApp. In my app, I need to query a database, then (based on results) add checkboxes to my form and set their "Checked" state. Since the controls are dynamically created, I'm using the OnInit event to create the checkboxes and set the "Checked" state from the DB. Next, I want to capture the postback event (AutoPostBack=true) and update my database based on...
4
5953
by: mahsa | last post by:
my problem dosent solve yet I want to have claa void in onclick of my check bov if I us function setProps ( ) msg.innerText = "llll"; in <datalist> <ItemTemplate><input type="checkbox" id="cbItem" runat="server" onclick="test() value='<%#DataBinder.Eval(Container.DataItem, "PartNo")%>' NAME="cbItem"><%#DataBinder.Eval(Container.DataItem, "PartNo")%><td class='item_content' width='83'><input value=4 maxLength='4' size='4'...
3
2026
by: DotNetJunkies User | last post by:
Hi, I have a checkbox control programmatically created for each row in the datagrid but CheckedChanged event not firing when state of the checkbox changes. I use the following code to instantiate ItemTemplate with checkbox contructor: public class TemplateObject : ITemplate { public void InstantiateIn(Control objContainer) { CheckBox objCheckBox = new CheckBox(); objCheckBox.ID = "Item";
1
4510
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a checkbox and I can't get it to default to checked. I tried radiobuttons and experienced the same result.. can't start them as checked. The really frustrating thing is that I set the attributes of other input controls in the Init() with no problem. ...
3
30624
by: Woo Mun Foong | last post by:
I have a checkbox, when enable, allows me to proceed with what I like to do. However, I need to check a certain conditions before I allow the checked box to be checked, if condition is not fullfill I need to cancel the Checked State. I captured the Mouse Click event inside CheckedChanged and CheckedStateChanged Events but it goes into infinite loops. I am using VB.NET 2003 and .NET 1.1 Briefly, my code is as follows:-
5
24526
by: c_shah | last post by:
using VB.net (2005) ASP.net 2.0 I have a repeater control with the item template, in the item template I have two checkboxes How to capture event When user checks the checkboxes? What event fires on the repeater Repeater Control Item Template
2
21044
by: =?Utf-8?B?UmljaA==?= | last post by:
Is there a cancel argument for cancelling if you want to check or uncheck a checkbox? In the checkChanged event of a checkbox I ask the user if they are sure they want to check/uncheck something. If No, I want to cancel the check or uncheck and cancel the click event. Right now I have a form level boolean checkvar that I set based on the user's response. If No then when entering the click event I don't perform various actions. Is...
3
2832
by: Ryanfromscotland | last post by:
Hey there everyone, this is my first post so be nice :-) I have wrote quite a bit so the actual question is written out at the end if you want to skip on and see if you can answer it without the rest of the info. I'm a hobbiest programmer and have taken up the project of writing a savestate editor - if you don't know what that is it's not really important - but I am having a bit of trouble with some code and google isn't turning up the answer...
1
6017
by: iderocks | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and when I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in a different event...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.