Click Event problem

S

Shelly

Here is the situation.
I have a button and I have the click event. When it is clicked, it enters
that subroutine (submit_Click). As part of the processing it checks two
sets of fields. If either of these sets fails (no checkbox checked, for
example), then an error message control is set and no further processing is
done and the page reappears with the error message presented.

Here is the problem:
WheIf I then set one of the check boxes so that it should pass the test, and
then click the submit button nothing happens. I also did this in the
debugger, but it didn't break in the submit_Click routine as it did the
first time.

Does anyone have any suggestions?

Shelly
 
G

Guest

Hi
Could you plzz ellaborate the exact problem that you are facing
could you give the code of your routine submit_click
 
S

Shelly

Nishant Rana said:
Hi
Could you plzz ellaborate the exact problem that you are facing
could you give the code of your routine submit_click

Protected Sub submit_Click(sender As Object, ByVal e As System.EventArgs)
Handles submit.Click
Dim checked as Boolean
checked = ValidateCheckBoxes()
If Not checked Then
errorMessage.Text = "Checkbox not set"
Else
errorMessage.Text = ""
End If
End Sub

The exact code inside the routine is irrelevent. I put those two lines in
this post to indicate that set a breakpoint at the "checked =" line. It
doesn't hit that line on the second try.

The first time I click the submit button, it stops at the breakpoint, then
calls the ValidateCheckBoxes function returning False. It sets the
errorMessage control's text value. I then, in the form, set one of the
check boxes that is to be validated so that it should then return True when
I resubmit. I again click the submit button but it doesn't break at the
"checked =" line. Nothing happens.

Shelly
 
G

Guest

Hi
I tried replication the scenario using a sample aspx
page with
2 checkboxes and a button
with a label for displaying error msg
In my case it was working fine

this is the code

protected void Button1_Click(object sender, EventArgs e)
{

Boolean check;
check = ValidateCheckBoxes();
if(check == true)
{
Label1.Text = "Checkbox not set";

}
else
{
Label1.Text = "";

}


}

private bool ValidateCheckBoxes()
{
if(CheckBox1.Checked == false && CheckBox2.Checked == false)
{
return true;

}
else
{
return false;
}
}
 
S

Shelly

Yes, it SHOULD work. That is why I posted it. It works the FIRST time I
clicked, but not the SECOND time. What could have happened in there so that
it doesn't fire the click event the second time?
 
S

Shelly

I have other events on the page that cause a refresh of the page. It seems
that if I fire one of those, then the submit button will fire, I only
doesn't seem to fire when the previous event was from that submit button.
(The other event I have on this page is an OnTextChanged event for one of
the other fields. If I change the value in that field and go to another
field, it fires the event, the page refreshes with information for several
fields using the changed value as the basis, and then I can fire the submit
button. Once that button is fired, however, it won't fire a second time.
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top