|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am currently running a ASP.net solution written in C#. The problem that Im running into is dynamic headers and footers. The directory structure is as follows:
/default.aspx <- main page in root /images /Controls/Header.aspx <- header control /Controls/Footer.aspx <- footer control /area51/default.aspx <- page that has the problems. What I have to do here is dynamically point all the image src attributes back one directory when in the area51 directory. I already have it working with running the HTML tag object at the server and appending the src attributes. I guess my main question is, what is the best way to do this? Also, is there a way to reference the instance of my control from the HTML view in the VS IDE? This would answer the whole issue. |
|
#2
|
|||
|
|||
|
This sounds to me like a simple HTML issue rather than an issue with ASP.NET or any other scripting / programming language for that matter.
I have always advocated referencing images or any links sitewide from the server; not from the page. A simple example of what you need to do: Images are here: /images I'm assuming you have links to images inside the header and footer files, which you have included in /default.aspx. When running /default.aspx you have no problem linking images because you are linking images like this: images/myimage.jpg when you should be linking to /images/myimage.jpg The reason the images show up when running /default.aspx is because the links are actually relative to the root directory... as there is no images directory under the area51 directory, this does not work for the /area51/default.aspx page.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
|
#3
|
|||
|
|||
|
The current application that I am designing has a requirement to have the images, hrefs, css etc links all dynamically generated. The application can be placed in /site1/logic or /site4/logic
I need it relative not absolute. Any suggestions? |
|
#4
|
|||
|
|||
|
Maybe I'm missing something, but why do you have to link everything relatively?
|
|
#5
|
|||
|
|||
|
This allows the app to run in any dir. Not just the root dir.
ie: Site1 /images /default.aspx Site2 /cluster1/images /cluster1/default.aspx if you have src="/images/someimage.gif" it will not work in site2 because it is absolute. Buy by having it relative to the dir that calls the image you dont have to change any code. Kewl? ![]() |
|
#6
|
|||
|
|||
|
Quote:
When you are in /default.aspx currentPath = "/" (empty). When you are in /area51/default.aspx currentPath = "/area51" Create links by appending the path with the rest of the link. Now, no matter where you put the application code your links should figure out where you are. |
|
#7
|
|||
|
|||
|
Easily said but not that easy to implement in C# ASP.net.
ASPX does not work the same as ASP pages. MS has seperated content from code. Try it yourself and I bet u will be sratching your head just as I am. Challenge: Reference a web control that have you made. The Catch: Call the variable from the HTML view in the VS IDE. Heres some more details. Make a control called Header. Define a public string (not static or const) called BASE and assign it "../". Add it to any aspx page, and try to get the value for BASE. I had no luck doing so. If you crack this challenge then it will solve my problem. Try it! Goodluck! ![]() Ask youself, how do I get the instance of my control from the HTML view (Content view) |
|
#8
|
|||
|
|||
|
I'd try it except I don't have an ASP.NET ready server to try it on.
All I can give you is a concept. I'm sure there is a way to do it... you might want to try digging through some of microsoft's documentation... I'm sure there is a reasonable way to do this. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Dynamic headers and footers with C# in ASP.net |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|