Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom error page scope problem

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
I have a custom error page that is being called successfully when I want it. At the top of the code I have an "Imports CfgLib" statement. Within CfgLib.vb I have code along the the following lines:
Code:
Public Shared CfgHoldFolder As String  
Public Shared Function CfgInitialise() As Boolean
  CfgHoldFolder = "\webtemplate\"
End Function
I then start debugging my project and the custom error page fires as expected and calls the CfgInitilaise function and I can step through the code of that function and verify that CfgHoldFolder is assigned. However, when control returns to the custom error page and I attempt to display the content of the CfgHoldFolder variable it displays "Name 'CfgHoldfolder' is not declared" although it will step through code that references the variable without crashing.

Where am I going wrong here please? I expected the variable to be available within the calling module (i.e. custom error page) and to contain the value assigned in CfgLib.
 
Thanks for the reply. There's a lot so I'll try and tie it down a bit first so I can provide a smaller sample.
 
I apologise. This was a red herring. I narrowed down the code to just a few lines and got the same symptoms - i.e. "Name 'CfgHoldfolder' is not declared" in debug window when I attempted to display its value but just for fun, I added one line of code:
Code:
MsgBox(CfgHoldFolder)
which displayed the correct variable content.

So the variable was being assigned but I just couldn't see it in the debugger. I'm sure there's a brilliant reason for that but very frustrating! I wasted hours on this.

Just for the record, my investigation was triggered by the fact that a Replace function didn't appear to be working in my code which was caused by the fact that one string (returned by Request.Url.LocalPath) had forward slashes while my CfgHoldFolder variable had backslashes and I didn't notice that difference. A lesson learned.

Thanks for forcing me to delve deeper!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top