Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 21st, 2006, 06:34 AM
Authorized User
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default image directory asp.net

I guys,

I am currently rewriting my asp application to ASP.net. The current file structure is as follow

dir: A
dir: B
dir: C
dir: Images
dir: Style

Dir A, B and C being directories that hold asp pages.
my question is how do i do this in ASP.net and how can i reference images from the image directory into my new ASP.NET pages


Old August 21st, 2006, 01:10 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Just like you normally would. E.g. from the A folder:

<img src="../Images/MyImage.gif" />


<asp:Image ImageUrl="../Images/MyImage.gif" runat="server" />

In addition to that, .NET also supports the ~ syntax where the ~ points to the application's root. This works only with server side controls (e.g. <asp:Image /> and <img runat="server" />):

Again, from the A folder:

<img src="~/Images/MyImage.gif" runat="server" />


<asp:Image ImageUrl="~/Images/MyImage.gif" runat="server" />


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
image on another directory tal ASP.NET 1.0 and 1.1 Basics 1 June 28th, 2007 05:37 PM
ASP.NET and directory security quintesv ASP.NET 1.0 and 1.1 Basics 1 September 26th, 2006 09:41 AM
ASP.NET, Active Directory integration. swadhinm ASP.NET 1.0 and 1.1 Professional 0 September 19th, 2005 04:31 AM
Local Directory Browsing problem in asp.net Ramakrishna General .NET 1 November 25th, 2004 05:05 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.