ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2003, 11:46 AM
raygig raygig is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 raygig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Dynamic headers and footers with C# in ASP.net

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.

Reply With Quote
  #2  
Old September 9th, 2003, 12:03 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
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.

Reply With Quote
  #3  
Old September 9th, 2003, 12:08 PM
raygig raygig is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 raygig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #4  
Old September 9th, 2003, 12:46 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Maybe I'm missing something, but why do you have to link everything relatively?

Reply With Quote
  #5  
Old September 9th, 2003, 12:56 PM
raygig raygig is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 raygig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #6  
Old September 9th, 2003, 01:13 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Quote:
What I have to do here is dynamically point all the image src attributes back one directory when in the area51 directory.
In your application code you need a variable that will hold your current location on the server. Call the variable currentPath.

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.

Reply With Quote
  #7  
Old September 9th, 2003, 01:24 PM
raygig raygig is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 raygig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
  #8  
Old September 9th, 2003, 02:55 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Dynamic headers and footers with C# in ASP.net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek