get application path

Hi experts

i have some folders in my asp.net application
and all aspx page use the same JS file

but when i need to call a page in a JS Function
the page is not found by some others pages

for example

root

-folder1
--subfolder
---page1.aspx

-folder2
--page2.aspx

-page3.aspx
-JSFile


as you can see i don"t know how to launch the page3.aspx when i'm in page1.aspx and n page2.aspx

for now i use this :

var url = "../page3.aspx"
it works for page2.aspx not for page1.aspx

i also tried this with no success : "~/page3.aspx"

any suggestion?

regards
LVL 2
Dnx_7Asked:
Who is Participating?
 
xlt77Connect With a Mentor Commented:
Oh?

For my option, "/page3.aspx" is the web site root + '/page3.aspx' .
If your web site is "http://www.yoursite.com" , and wherever your current path is, your can redirect to "http://www.yoursite.com/page3.aspx" with link '/page3.aspx' .

The path analysis rule is :
./  -- current path
../ -- parent path
/   -- root path

Or, you can use  'http://'+document.domain + '/page3.aspx' to visite page3.aspx wherever your current path is.
0
 
xlt77Commented:
Use absolute url.
such as :  
/page3.aspx
/folder2/page2.aspx
/folder1/subfolder/page1.aspx
0
 
Dnx_7Author Commented:
hmm

is there no way to use a single path for calling page3.aspx
wherever i am in the website?

because if i do that : "/page3.aspx"
then if i am in the page2.aspx
and call the js function
the client will try to get that page : /subfolder2/Page3.aspx


regards
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Dnx_7Author Commented:
i see

in fact i use a window.open("/page3.aspx"...)


don't you think there is something different?

0
 
NightfalconCommented:
Hi Dnx_7,

It all depends on where you use the window.open-instruction.

If you call this from the root, you should use window.open(./page3.aspx) (using your current path)
If you call this from page1.aspx, you should use window.open(../page3.aspx) (using the parent path from your current location)

Hopes this helps

Night
0
 
Dnx_7Author Commented:
in fact i don't know where i can call the page that's why i wish to use a full path (generic path) for calling the page3.aspx wherever i am in the website

in many page i just call the function

doIt(urlParam);

and the doIt function open the urlParam

regards
0
 
Dnx_7Author Commented:
thanks i use that way : document.domain...

regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.