473,320 Members | 2,161 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,320 software developers and data experts.

Try and Catch Problem

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;

}
Nov 16 '05 #1
2 1419
Brian Conway <Br**********@qwest.com> wrote:
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;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
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

"Brian Conway" <Br**********@qwest.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
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;

}

Nov 16 '05 #3

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

Similar topics

10
by: Bungle | last post by:
Hi I am trying to do something really simple. Create a method within a class which will connect to the database, pull back a result and return it out the method. Not hard. All my database...
69
by: Nay Myo Aung | last post by:
Hi All! I think I discovered a possible improvement on .NET Framwork's TRY...CATCH...END TRY statement. I guess most developers might also have been discovered that at some point in their .NET...
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
7
by: Tiraman | last post by:
Hi , I am using allot the try catch in my code and the question is if it is good ? it will decrease my performance ? one more question
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.