Try and Catch Problem

  • Thread starter Thread starter Brian Conway
  • Start date Start date
B

Brian Conway

I am trying to catch and error in my code, it works fine when testing it
with a Label Visible set to True, however, I want it off unless there is an
error and then I want the property set to True from False, however, when I
turn it off in the properties and try coding with the following code, it
does not turn on the Visible property of the label any ideas? C# Webform
btw

catch(System.Exception caught)

{

lblErrorMessage.Visible.Equals("True");

lblErrorMessage.Text = DuplicateCUID;

return;

}
 
Brian Conway said:
I am trying to catch and error in my code, it works fine when testing it
with a Label Visible set to True, however, I want it off unless there is an
error and then I want the property set to True from False, however, when I
turn it off in the properties and try coding with the following code, it
does not turn on the Visible property of the label any ideas? C# Webform
btw

catch(System.Exception caught)

{

lblErrorMessage.Visible.Equals("True");

lblErrorMessage.Text = DuplicateCUID;

return;

}

Equals() is used to *test* equality, not to *set* a value. You should
use:

lblErrorMessage.Visible = true;
 
Brian,
The correct format for setting visibility is as follows:

lblErrorMessage.Visible = true; //to see the label
lblErrorMessage.Visible = false; //to hide the label

Good luck,

Amadelle
 

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

Similar Threads


Back
Top