Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Click Event problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shelly - 19 Sep 2007 14:39 GMT
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
Nishant Rana - 19 Sep 2007 15:34 GMT
Hi
Could you plzz ellaborate the exact problem that you are facing
could you give the code of your routine submit_click
Shelly - 19 Sep 2007 15:55 GMT
> 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
Nishant Rana - 19 Sep 2007 16:14 GMT
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;
       }
   }
Shelly - 19 Sep 2007 16:44 GMT
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?

> Hi
> I tried replication the scenario using a sample aspx
[quoted text clipped - 35 lines]
>        }
>    }
Shelly - 19 Sep 2007 16:49 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.