Custom Server Controls :: Make Root Relative Path?

Jul 26, 2010

I'm creating a custom server control which needs to take in a root-relative path for one of it's properties. I use the UrlProperty, but when I select a file in the markup, the selected path doesn't inlcude the the "~/". I'd like to mimic the behavior of a hyperlink. So let's say I have this:

<asp:HyperLink ID="HyperLink1" NavigateUrl

When I type in an equals sign after the NavigateUrl property, intellisense pops open a URL picker and I can pick from any page to produce this code:

<asp:HyperLink ID="HyperLink1" NavigateUrl="~/default.aspx"

this code has the "~/" in front. When I use my control, I have this:

<cc1:TestControl ID="TestControl1" Url="default.aspx"

the C# code has this property:

[UrlProperty]
public string Url { get; set; }

Does anyone know how I can make the "~/" be placed in front to make a root-relative path?

View 3 Replies


Similar Messages:

Web Forms :: Server.MapPath Displays Path As Relative?

May 4, 2010

I have a web application that uses Server.MapPath to specify the exact physical path of as part of upload image.

For example if I do Server.MapPath("/")

I get this:

\boswinfs04homeusersweb2676username

I was expecting something like this:

d:folder

I need to use Server.MapPath not only for image upload but several other uses.

View 2 Replies

Mapping Of Relative Path To Absolute Path Of Webpage Links?

Apr 8, 2010

I am Final Year IT Engineering student. I am Doing Content Management System in ASP.net for my college. I have given link on my master page for various pages in the application; where I have specified only relative path of those pages. When I run this project and follow any link it works well for only first time and for second time when I click any link it .net run time environment unable to find the absolute address of that page.

View 2 Replies

C# - How To Select A Folder Relative To Root In Website

Jul 29, 2010

I am trying to select all the files from a folder in my website and store them in a collection. The problem is that when I run the website it is not selecting the folder in my website:

This is the basic structure: [Root Folder] --> [FilesFolder]

Here is the code I am using:

DirectoryInfo dir = new DirectoryInfo("FilesFolder");

But it is showing this at runtime as the location of the folder:

C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0FileUploads

Is there a way to select the folder relative to the root of the website?

I am using C# with ASP.NET 3.5

View 2 Replies

URL Rewrite Breaks Root Relative Paths?

Jan 27, 2011

I have a website, lets call it mywebsite.com. I also have a blog at mywebsite.com/blog. I have made a URL rewrite rule so it can be accessed from blog.mywebsite.com. The issue is that all my root relative paths (~/) do not work when viewing the blog from blog.mywebsite.com. Ok, say if there is a link on my blog that goes to a blog post that is at ~/blog/post.aspx?id=1. It will then go to blog.mywebsite.com/blog/post.aspx?id=1 which is actually, mywebsite.com/blog/blog/post.aspx?id=1 and that does not exist.

View 3 Replies

Converting Relative Path To Tilde Path?

Apr 4, 2010

I have this master page, that uses a few .js files and a flash animation.

the <script> and <object> tags that are used to embed these in the page take in relative paths as src. However, since the pages .aspx, i'll need to convert these into tilde paths, ie. somehow change the relative paths to tilde path (is this the absolute path?), so that i can use the master page in any of my pages in subfolders as well. if this question has been posted b4, kindly give me a link... i've not been able to find a solution.

View 3 Replies

MVC :: Routing Relative Path Instead Of Absolute Path?

Jun 9, 2010

When I write following code in my view

<% Url.Action("Logon") %>
the mvc framework generates
/Account/Logon ({controller}/{action})
as path.
'/Account/Logon' path is an absolute path. Is there a way to change is to a relative path, like Account/Logon or ../Account/Logon.

Also, when I use the Html.Beginform(), the mvc framework generates <form action="/account/logon"..., I want to change this to <form action="account/logon"...So, problem is that I want relative paths instead of absolute path.

View 6 Replies

C# - Absolute Path And Relative Path?

Oct 13, 2010

i am fetching image using webservice into dataset and displaying for that its to be get worked after deployment i have done following line of code but its still not able to display the image after deployment

String imageName = row["ImageName"].ToString();
String physicalPath = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
String imagePath = physicalPath.Substring(0, physicalPath.LastIndexOf("/",
StringComparison.OrdinalIgnoreCase) + 1) + imageName;

View 3 Replies

Custom Server Controls :: Getting Source Path Of Registered Controls By Tagname?

Jan 15, 2010

I have some user controls registered in the web.config.

Now I need to load some of them dynamiclly with the page.loadcontrol() function. This function needs a virtual path to the .ascx file. Is it possible to get this virtual path (that is the same as the source path in the config) by the tagname?

View 1 Replies

How To Get A Relative Path In MVC

Sep 9, 2010

How do you calculate a relative path in ASP.NET MVC?

View 2 Replies

Custom Server Controls :: Figure Out The Absolute Path To App_data Folder On Project?

Mar 31, 2011

I have an user control that reads the data from app_data folder and does some processing.In design time I'd like to show the row data in control placeholder (using GetDesignTimeHtml).To do that I need to figure out the absolute path to app_data folder on my project.The HttpContext is not available and HostingEnvironment.MapPath returns null.

View 3 Replies

Getting Relative Path In JavaScript?

Jun 21, 2010

I've got this app where I'm using an IHttpHandler to serve JSON data to my JavaScript method.

[code]....

This works fine on my "localhost" webserver, but I've also got a staging server for my clients to use. http://staging.infinitas.ws/ClientSite/

The problem that I'm having is that when the app is hosted on the staging server, the theSource is mapped incorrectly (contains /ClientSite/). I could do something like a String.Replace but I'm looking for a more elegant way of achieving this.

View 1 Replies

Get A FileStream From A Relative Path?

Apr 24, 2010

I am trying to get a FileStream from a relative path. The file is in my project, but when I try to do that it automatically appends C:\ in front of that.

1. Does the FileStream only works if the file is on a local Hard Dive?

2. Also if it works from the local hard drive, then does my application needs some permission to read the file from C Drive?

View 2 Replies

.net - Absolute Vs Relative Path?

Dec 14, 2010

Possible Duplicate: Absolute path & Relative Path

When to use absolute path, relative path and what is the difference between both?

View 2 Replies

Relative Path - Different Project?

Sep 20, 2010

I have three projects inside my solution and i using some same images on all of three projects. How can i create relative path from one project to another?

View 4 Replies

Web Forms :: How To Return A Relative Path

Apr 19, 2010

what it does at the moment is return an absolute path for example h:myfile . however, this is causing me problems because when browsing to the page, it is not returning the file i need because it is looking for a h: drive which the client machine does not have. so i was thinking i need to return a relative path so the not looking straight to the h: drive and rather it is just looking for the filename. i have also created this as a virtual directory on iis which is where is looks for the file location.

View 8 Replies

C# - Calculating Relative Path Change?

Oct 6, 2010

Assuming I have a .css file with the following linebody { background-image: url('../images/bg.png') }My build process does some CSS magic and eventuall move this file from
~/Content/styles/styles.css
To
~/temp/styles.css

This invalidates the url statement in the file and needs re-written to ../Content/images/bg.pngThis is my question - given the original file location, the new file location and the background-image url in the file is there a reusable way calculate a new relative path for the image?In case someone doesn't know css urls should be relative to the css file it is contained within.

View 2 Replies

Load A Pdf File With Relative Path?

Dec 7, 2010

my asp.net program have to open pdf files, these files are contained in a directory named "pdf",

The problem is: The webpage doesn't find the relative directory "/pdf" ; to solve the problem I have to write the exaclty path "C:inetpubwwrootsitepdf" butI want to use only the relative path to avoid other problems.

View 1 Replies

C# - Use A Relative Path In XDocument.Load?

May 6, 2010

I have an XML file named PageData.xml in my App_Data folder. I want to populate an XDocument with this file using XDocument.Load.

If I supply the full physical path it works, i.e.:

XDocument vXDoc = XDocument.Load("/Work/Project/Web/100413 Dev/App_Data/PageData.xml");

...where "Work" is a folder on my C: drive.

If I try a relative path like this, though, I get a DirectoryNotFoundException:

XDocument vXDoc = XDocument.Load("AppData/PageData.xml");

"Could not find a part of the path 'C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0AppDataPageData.xml'."

This is obviously wrong, but there must be an easy way to set the correct relative path?

View 1 Replies

MVC :: Relative Virtual Path Is Not Allowed Here?

Oct 29, 2010

OK, I've seen a lot of ambiguous errors, but this was is in the top 20 or so. I have a RenderPartial that looks like this:

[Code]....

When the view loads, I get this error:

The relative virtual path '~Areas/User/Views/Shared/ProjectStats.ascx' is not allowed here. That really helps. Why isn't it allowed there? What's wrong with it? Just above it I have other PartialRender calls that work without a problem. They're created exactly the same way. Here's another:

[Code]....

This works fine. I thought maybe it was due to accessing a view from another Area, but I added a partial view to that Area's folder and it still didn't work.

View 3 Replies

MVC :: Get View Relative Path In Code Behind

Jan 22, 2010

i would know if is possible and how i can retrieve the current relative path of the view that is executed. The code is in a model file (C#)

View 2 Replies

Get A Path Relative To The Current Address?

Jan 22, 2010

Suppose I have a resource located in ~/Resources/R1.png This resource's relative URL will vary depending on the current address.

For instance: If I'm at www.foo.com/A/B/C/D.aspx and the www.foo.com/A is the root path including Virtual Directory, then the path relative to the current address of ~/Resources/R1.png is ../../../Resources/R1.png

How can I get this relative path?

EDIT:

I want a web path that I can use in a web page, not a server path.

View 4 Replies

Get The Relative Path In The Class Library?

Sep 7, 2010

I have to access a relative path of the XSD file to validate a XML file. The XML file and the XSD file are part of the class library. How do I access the relative path in the class library?

In case of website, I would use server.mappath(path). Is there anything similar to get the virtual path to the corresponding physical directory on the server in the class library?

View 2 Replies

Configuration :: Relative Path For Data Source?

Oct 8, 2010

I am doing SOA architecture and the data base is in service side ie.within the project(website 7)

how can i can mention relative path for the data source ?

OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\sathiyabalu\My Documents\Visual Studio 2005\WebSites\WebSite7\App_Data\alumni_member.mdb");

View 1 Replies

C# - How To Secure Web Service To Only Allow Relative Path Calling

May 19, 2010

I have ASMX services for my web application that I would only like available to the same application.Is there a way for the web service to only be accessible by the same application, such as relative/absolute path restrictions?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved