By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,459 Members | 1,472 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,459 IT Pros & Developers. It's quick & easy.

Button Click event not working properly

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.