How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom 7 4264
Try:
if(Page.FindControl("myobjectid")!=null) // It's there
tshad wrote:
How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
If(UserLoggedOn != null){
UserLoggedOn.visible = true;
}
"tshad" wrote:
How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
<mi*******@hotmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Try:
if(Page.FindControl("myobjectid")!=null) // It's there
William mentions:
If(UserLoggedOn != null){
UserLoggedOn.visible = true;
}
Which is better or is it 6 of one...?
Thanks,
Tom
>
tshad wrote:
>How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
Agreed...
William Sullivan wrote:
If(UserLoggedOn != null){
UserLoggedOn.visible = true;
}
"tshad" wrote:
How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
Well, I say that... unless you have a direct reference to the object,
you will need to do the FindControl. If it's directly accessible by
programmatic means, you wouldn't have to.
michae...@hotmail.com wrote:
Agreed...
William Sullivan wrote:
If(UserLoggedOn != null){
UserLoggedOn.visible = true;
}
"tshad" wrote:
How do you check to see if object exists before accessing it?
>
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
>
UserLoggedOn.visible = true
>
If this doesn't exists, I get an error.
>
So how do I test for the object (vb.net and C#) before doing this code?
>
Thanks,
>
Tom
>
>
>
if (UserLoggedOn != null) UserLoggedOn.visible = true;
-- bruce (sqlwork.com)
"tshad" <ts**********@ftsolutions.comwrote in message
news:u4**************@TK2MSFTNGP06.phx.gbl...
How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I
need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
Try:
if(Page.FindControl("myobjectid")!=null) // It's there
Not always: if "myobjectid" is a "grandchild" (child of another control
on the page) or deeper, then FindControl will not find it as it
searches only through the direct children.
Hans Kesting
>
tshad wrote:
>How do you check to see if object exists before accessing it?
For example, I may have an object that I make visible and invisible and I need to make sure it exists as I am putting this code in a User Control.
UserLoggedOn.visible = true
If this doesn't exists, I get an error.
So how do I test for the object (vb.net and C#) before doing this code?
Thanks,
Tom
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David |
last post by:
My email application was working a couple of weeks ago,
then all of a sudden I get
Error Type:
(0x8009000F)
Object already exists.
I checked the permissions on the machinekeys directory...
|
by: Uttam |
last post by:
Hello,
How does one suppress the "Object already exists" message when the
following statement is executed in ADO?
cat.Views.Append "Some_Query", cmd
Thanks in advance.
Uttam
|
by: Geiregat Jonas |
last post by:
is using
if(open("file",O_EXCL) != -1){ printf("File does
exists")}else{printf("file does not exists"); }
a good way of checking if a file exists or not, if not how should I do it ?
|
by: M Keeton |
last post by:
I'm building a web site and I need to link to an external page which at any
one time may or may not exist (server is not always on). What I need to do is
check before redirecting to this page...
|
by: Alun Jones |
last post by:
I'm getting the above error in a dialog box from Visual Studio 2005 when
trying to sign an assembly using a PFX file, and would like to know how to
resolve the problem.
Background:
The PFX...
|
by: =?Utf-8?B?R2FicmllbCBNw6luZGV6?= |
last post by:
Hello everyone.
I have a small class that encapsulates some functionallity to work with the
RSACryptoServiceProvider. Here is the code of the class i'm using:
public class dsRSA
{
private...
|
by: oll3i |
last post by:
how to check if an object already exists and return reference to that object
|
by: Alan |
last post by:
Hello,
I need to write a systemtray program to check every minute if a
certain intranet page exists. Would "webBrowser.Navigate" and catching
exceptions to it be a good choice in terms of load...
|
by: ThatsIT.net.au |
last post by:
I'm getting a 404 error when I shouldn't, the page exists
the error is
The remote server returned an error: (404) Not Found.
the status is 7 witch equates to WebExceptionStatus.ProtocolError
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |