473,714 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Test if Object exists

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.Naviga teUrl="http://www.staffingwor kshop.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("SiteSo urceCompany") is nothing then
Line 42: if not HomeLink is nothing then
HomeLink.Naviga teUrl="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
Aug 7 '07 #1
2 2637
What you probably want to do is to use FindControl to see if it exists or
not, that will prevent the compile error. In this context 'this' is the
current page.

HyperLink hl = this.FindContro l("HomeLink") ;
if (hl != null) {
hl.NavigateUrl= "http://www.staffingwor kshop.com/"
}

John
Nice Clean Examples
www.nicecleanexample.com

"tshad" <t@home.comwrot e in message
news:er******** ********@TK2MSF TNGP04.phx.gbl. ..
>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.Naviga teUrl="http://www.staffingwor kshop.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("SiteSo urceCompany") is nothing then
Line 42: if not HomeLink is nothing then
HomeLink.Naviga teUrl="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


Aug 7 '07 #2
On Aug 7, 12:54 pm, "tshad" <t...@home.comw rote:
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.Naviga teUrl="http://www.staffingwor kshop.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("SiteSo urceCompany") is nothing then
Line 42: if not HomeLink is nothing then
HomeLink.Naviga teUrl="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.
Aug 7 '07 #3

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

Similar topics

25
3900
by: Treetop | last post by:
I have seen some codes that can test for the browser and give values accordingly. I tried to read the FAQ, but was unable to find a simple version of this. What I want is If Netscape-test { code for netscape users } If IE-test { code for ie users
11
23052
by: Squid Seven | last post by:
I create a pointer to an item: CardSession *cardSession; Then, later, I use new to create an instance of the item and assign it to that pointer: cardSession = new CardSession(); In another function, I want to test if an object is assigned to that
3
21618
by: Steve Montague | last post by:
How does one test to insure a property of an objects exists? The debugger shows the object.property as: "error: 'object.property' does not exist" using: if (object.property != null) results in: "Object reference not set to an instance of an object." Thanks for help!
13
1881
by: DC Gringo | last post by:
How do I test for existence of a file in the file system: If FileExists(myVariable & ".pdf") = True pnlMyPanel.Visible = True End If -- _____ DC G
6
15437
by: Darren Linsley | last post by:
I know this might seem like a dumb question, but how do you test that an object exists. Maybe i should explain a little. I have a variable that points to an object. Now if that oject is released, how can i test my variable to see if the object it was pointing at, still exists? Please help!!
13
9553
by: joenuts | last post by:
Is it possible for a function to test one of it's passed in variables (reference to object) for validity? I would like the displayString( string &obString) function to verify that obString 1) exists 2) is a valid string object. calling any methods of said object cause a seg fault if the object doesnt exist. (code to follow) #include <string> #include <iostream> #include <vector>
6
3119
by: Vmusic | last post by:
Hi, I am using Javascript to add rows to tables, etc. in a function I am calling. I pass the function the ID of the div, and what I want in the rows, and it will add rows to a table in the div. The problem is I need to test for the existence of the table - and if the variable or object doesn't exist already my code errors - PLEASE REMEMBER - I don't know the name of the variable or object I am testing the existance for - it is created...
2
2432
by: Netkiller | last post by:
#!/usr/bin/python # -*- coding: utf-8 -*- """ Project: Network News Transport Protocol Server Program Description: 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子 Reference: NNTP协议: http://www.mibsoftware.com/userkt/0099.htm 正则表达式: http://wiki.woodpecker.org.cn/moin/RegExpInPython#head-2358765384844ed72f01658cbcde24613d941e9d
9
1569
by: wildernesscat | last post by:
Hello there, I'm looking for a method to test, whether an object has a certain property. Consider the following snippet: class A { var $aaa; } $var = new A; (Assuming that the structure of class A is unknown) I need a way to
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8707
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9314
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7953
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.