Test if Object exists

T

tshad

I have an object that may or may not exist on a page. Therefore, I test for
it. But it doesn't seem to work if I do the following:

if not HomeLink is nothing then
HomeLink.NavigateUrl="http://www.staffingworkshop.com/"

I get the error message:
********************************************************************
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'HomeLink' is not declared.

Source Error:

Line 40: if not isPostBack then
Line 41: if Session("SiteSourceCompany") is nothing then
Line 42: if not HomeLink is nothing then
HomeLink.NavigateUrl="http://www.stw.com/" <-- error
Line 43: end if
Line 44: Dim OldStart = Session("start") 'Keep this as the clear will
dump it
***********************************************************************

How do I test to see if an object exists or not?

Thanks,

Tom
 
L

lee whitbeck

I have an object that may or may not exist on a page. Therefore, I test for
it. But it doesn't seem to work if I do the following:

if not HomeLink is nothing then
HomeLink.NavigateUrl="http://www.staffingworkshop.com/"

I get the error message:
********************************************************************
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'HomeLink' is not declared.

Source Error:

Line 40: if not isPostBack then
Line 41: if Session("SiteSourceCompany") is nothing then
Line 42: if not HomeLink is nothing then
HomeLink.NavigateUrl="http://www.stw.com/" <-- error
Line 43: end if
Line 44: Dim OldStart = Session("start") 'Keep this as the clear will
dump it
***********************************************************************

How do I test to see if an object exists or not?

Thanks,

Tom

That should work, but you must declare HomeLink, which is why the
compiler is complaining. Once you have it declared in your code, you
can check if it exists or not.
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top