473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Getting path/directory of aspx file from within user control

I need some help with this.

I have two files
page.aspx: A page that a user calls

uc.ascx: A user control that page.aspx uses. The ascx file has HTML used
for a site background which would display one of two images. If page.aspx is
in the root directory, the displayed image has no text. If page.aspx is
anywhere but the root directory, the displayed image has "Home" on it. I
already created these two images, so I simply have to call the right image
URL from the user control.

Unfortunately, I don't know how to go about writing this part of the code.
FileInfo and DirectoryInfo classes require a path, but how do I tell these
classes to check the current page's location (not uc.ascx's location)? I
would like only one uc.ascx file.

Thanks.

Nov 17 '05 #1
2 2458
Quick and Dirty or maybe not.

I would create a property in the uc.ascx class.
Pass a value from the .aspx file (Page Load event would work) to the
uc.ascx class. Indicating which image to use.
In the set{} of that property you could then assign the correct Image
URL to an Image control for example

Nov 17 '05 #2
Kevin,
Thanks for the response.

I just found that within the control file (uc.ascx), I can use
Page.TemplateSourceDirectory to get a directory name. I can check the string
and compare it to my root directory string. I have to go test this.

I think this might be more "efficient" than letting the page send a value to
the user control, but if the above fails, I can try your idea.

"Kevin" wrote:
Quick and Dirty or maybe not.

I would create a property in the uc.ascx class.
Pass a value from the .aspx file (Page Load event would work) to the
uc.ascx class. Indicating which image to use.
In the set{} of that property you could then assign the correct Image
URL to an Image control for example

Nov 17 '05 #3

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

Similar topics

6
by: john_williams_800 | last post by:
Hi; I am writing an html page that will live on one server in an ms windows network, but access pictures from a directory on another ms windows server in the network. I know in html the...
2
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet...
6
by: Water Cooler v2 | last post by:
How does one get the root of the ASP.NET application. For instance, my application is: http://localhost/MyApplication/login.aspx Today, it is on a test server, but when I move it to the...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.