CheckBox CheckChanged Event

J

Jim Heavey

I have two checkboxes on a form. I changed the Autopostback to "true".
I code for the check change event. When I click one of the checkboxes,
it does perform the Page load event, but does not perform the Check
Change event.

I do not see in the windows generated code (C#) that it generated the
code "register" of the event. Should I? I am using VS.Net, and I would
have thought it would of registered the event. How do I get the event
registered, or is that even my problem?

I added the code for the event as follows....

I first Double click on the Event and that created the "method pattern".
I then changed the name of this method, as I was going to call it from
several places. I then went back in the IDE and pasted the new name
there in all of the controls that I needed the method for...

Thanks in advance for your assistance!!!!!!!!!
 
S

Shimon Sim

Do you handle !IsPostBack. For post back to work you must handle all the
initialization of the page in if(!IsPostBack)
Shimon
 
N

Nevyn Twyll

In the code-behind page, there should be a Web Form Designer generated code
section containing a method:

private void InitializeComponent()

And in that method, you need to register the checkChanged event, like this:
this.chkMyCheck.CheckedChanged += new
System.EventHandler(this.chkMyCheck_CheckedChanged);

Hope that helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top