How to get PATH?

M

Mark

I have an application the uses usercontrols (sidebar.ascx, sidebar1.ascx,
ect.))to display a side menu with content that will vary depending on what
folder the user is currently accessing.
like this:
root/folder1/somepage.aspx or root/folder2/somepage.aspx

I think there should be an easy(?) way to get the path of the folder
containg the page the user is trying to access to load the proper .ascx page
into the user control. The ascx pages are different depending on the folder
accessed. Is this possible?
The only other way I can think of to do this is to just put the proper .ascx
page into each folder and access them that way.

Something like this:

If Path = root/somefolder1/ Then
usercontrol=sidebar1.ascx
ElseIf Path= root/somefolder2/ Then
usercontrol=sidebar2.ascx
End If

TIA,
Mark
 
J

Jos Branders

Mark said:
I have an application the uses usercontrols (sidebar.ascx, sidebar1.ascx,
ect.))to display a side menu with content that will vary depending on what
folder the user is currently accessing.
like this:
root/folder1/somepage.aspx or root/folder2/somepage.aspx

I think there should be an easy(?) way to get the path of the folder
containg the page the user is trying to access to load the proper .ascx page
into the user control. The ascx pages are different depending on the folder
accessed. Is this possible?
The only other way I can think of to do this is to just put the proper ..ascx
page into each folder and access them that way.

Something like this:

If Path = root/somefolder1/ Then
usercontrol=sidebar1.ascx
ElseIf Path= root/somefolder2/ Then
usercontrol=sidebar2.ascx
End If

If each subfolder has its own usercontrol, obviously it's better to just
put the proper usercontrol into each folder.

If somehow, some of the usercontrols are common to multiple subfolders,
then you can retrieve the path with Page.TemplateSourceDirectory

More about paths in ASP.NET:
http://west-wind.com/weblog/posts/269.aspx


Jos
 

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

Top