Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Reference to the site root
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reference to the site root

 Post Reply Post Reply
Author
sardawg View Drop Down
Newbie
Newbie
Avatar

Joined: 17 May 2002
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote sardawg Quote  Post ReplyReply Direct Link To This Post Topic: Reference to the site root
    Posted: 10 March 2003 at 2:10pm

I was just beginning to get a handle on ASP and now I have to drink the .NET through a firehose.  Oh well...

In a piece of code just like this one (so ignore any parts not directly relevant to the question): 

       objMyUserControl = CType(LoadControl
("UserControls/SelectArea.ascx"), SelectArea)
        AddHandler objMyUserControl.MyEvent, AddressOf ucSelectArea

I had to point to the root of the site. Remembering something from ASP, I inserted "../" just on front of the "UserControls/DSelectArea.ascx", making it:

"../UserControls/DSelectArea.ascx" which solved the problem.

In a later code example in the Wrox Press book I am using for a tutorial, they used "Request.ApplicationPath & Path.AltDirectorySeparatorChar & "UserControls/DSelectArea.ascx" to also solve the problem.

My question is, is there a reason like security or something why you should use all the code instead of 3 characters?

And/or, couldn't you put a variable in global.asax named "root" and set it equal to "Request.ApplicationPath & Path.AltDirectorySeparatorChar &" so when you needed a reference you could use "root/UserControls/DSelectArea.ascx" to get there?



Edited by sardawg
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 11 March 2003 at 7:07am
Originally posted by sardawg sardawg wrote:

My question is, is there a reason like security or something why you should use all the code instead of 3 characters?

maybe since it was a book to teach, they are trying to expose as much as the stuff available

Originally posted by sardawg sardawg wrote:

is there a reason like security or something why you should use all the code instead of 3 characters?

well, security isn't an issue, but what if you moved this file one more folder deeper? yup, your code with "../" (which says: go up one folder, then into the UserControls directory) would no longer function, since now you'd have to go up two levels (ie: "../../")

Originally posted by sardawg sardawg wrote:

And/or, couldn't you put a variable in global.asax named "root" and set it equal to "Request.ApplicationPath & Path.AltDirectorySeparatorChar &" so when you needed a reference you could use "root/UserControls/DSelectArea.ascx" to get there?

you could do that (of course your syntax would have to be: root & "UserControls/De....blahb lah"), but of course you could just say:
objMyUserControl = CType(LoadControl
("/UserControls/SelectArea.ascx"), SelectArea)

which'll know where to go no matter where you are in the application




Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.