473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Button Click event not working properly

I have created an application that has a command button. The button is clicked and the click even contains code that looks like the following:

private void cmdCall_Click(object sender, System.EventArgs e)
{
this.lblState.Text = "Attempting Connect";

try
{
int callTest;
callTest = cell.callSite(this.txtPhone.Text);
if(callTest == 1)
{
this.lblStat.Text = "Connected";
}
else
{
this.lblStat.Text = "No Answer";
}

}
catch(Exception ex)
{
this.lblStat.Text = "Error";
this.lblError.Text = ex.ToString();
}
}

The first lblStat.Text = "Attemp Connect" does not trigger. The rest of the function works properly. But for some reason the Attempt Connect does not appear in the label that have made. This happends in other click events too. It is also a problem with one of my page load events. I use VS.Net 2003. Is there something that I need to do in order for this to work properly? I could use a timer. But I don't think I should have to do something that complex for this problem.

Thanks for your help -
Andrew
Nov 15 '05 #1
2 6057
Your code calls the label lblState at the top and then there's lblStat
further into the code. I am assuming they're the same and that one name or
the other was just typed incorrectly.

If that is the case, then the answer to your question is to add the line
Application.DoEvents(); after setting the label text to "Attempting
Connect.". That let's the system take a breather and catch up on things
like painting windows and labels, etc.

Hope that helps,

Dale

"Andrew" <an*******@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
I have created an application that has a command button. The button is clicked and the click even contains code that looks like the following:
private void cmdCall_Click(object sender, System.EventArgs e)
{
this.lblState.Text = "Attempting Connect";
try
{
int callTest;
callTest = cell.callSite(this.txtPhone.Text);
if(callTest == 1)
{
this.lblStat.Text = "Connected";
}
else
{
this.lblStat.Text = "No Answer";
}

}
catch(Exception ex)
{
this.lblStat.Text = "Error";
this.lblError.Text = ex.ToString();
}
}

The first lblStat.Text = "Attemp Connect" does not trigger. The rest of the function works properly. But for some reason the Attempt Connect does
not appear in the label that have made. This happends in other click events
too. It is also a problem with one of my page load events. I use VS.Net
2003. Is there something that I need to do in order for this to work
properly? I could use a timer. But I don't think I should have to do
something that complex for this problem.
Thanks for your help -
Andrew

Nov 15 '05 #2
Thanks for the reply - what if this is a ASP.net application

the DoEvents does not appear within the Application class

- Andrew
Nov 15 '05 #3

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

Similar topics

6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
1
by: sonic | last post by:
I generate a button link control in following Manner. Button b = new Button(); b.Click = MyEventHandler(...); If i add this button to current control with: this.Controls.Add( b ); it will...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
4
by: glbdev | last post by:
Hi, I posted this question yesterday but didn't get the answer I needed. I am DESPERATE to get this working so I'm re-posting it because I don't think I worded it correctly. I have a GridView...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.