Refrencing the Root Path/URL
http://www.csharpfriends.com
World's Greatest C# Community    
Home Articles C# Forums Books C# Syntax C# Spec C# Jobs free Source Code Advertise About
 

Control Panel

[ Sign In / register ]
Points   
Notes 
My Forums
My Tutorials
My Profile

Resources

Learn
 Articles
 QuickStarts
 C# Spec
 Whitepapers
 Tools
 Class Browser
 C# Code Generator
 Links
 Misc Rss Feeds
 Code Highlight
 411 Directory
 FREE magazines
 freevb.net

Reviews
  ASP.NET Hosting

Source Code
 Get Version 1.0



C# Consulting
AspDotNetStoreFront
Current Tip:
Refrencing the Root Path/URL
 
[prev. Lesson]  Screen Scraping in ASP.NET [next Lesson]  URL Rewriting
Refrencing the Root Path/URL  by: Salman

A common question from newbies is "How can I reference the root path of my application from controls?".  It is common for many server side controls to have properties such as src (source) and hyperlinks/URL etc.  ASP.NET has a neat syntax that you can use to reference the root of the applications directory in any server-side controls URL property.  This syntax will relief you of having to place relative pathis in your apps directory hierachy.

Simply prefix the path with the ~ (tilda) character.  During the compilation process of the server-side control, ASP.NET will translate that ~ into Request.ApplicationPath.

An example would look like <img src="~/images/logo.gif" runat="server">.  Keep in mind that this will work for SERVER-SIDE controls only!

 

   
Current Tip:
Refrencing the Root Path/URL
 
[prev. Lesson]  Screen Scraping in ASP.NET [next Lesson]  URL Rewriting



Today's Top Movers

Yesterday Top Movers


Monthly Leaders

Top Members

Great Offers
.net hosting
Go To My Pc
Remote Pc Control
C#
ad server
snadtech GoToMyPc

Top of Page

Advertise | SiteMap | About | Link To Us | Privacy Notice Copyright © 2003 - 2005 CSharpFriends.com  All Rights Reserved  Visual C# Developer Center