This is a migrated thread and some comments may be shown as answers.

How to get ~/ value

4 Answers 69 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Per Holmqvist
Top achievements
Rank 2
Per Holmqvist asked on 30 Dec 2007, 08:09 PM
When working with ajax more and more needs to work with javascript, not surprisingly ;)
But then I many times need to get my "application-root" as in runat=server "~/"
is there a way to get this?
Like me.application.root or something?

Not really a telerik related Q but often neede in telerik ajaxified prmotheus controls. :)

4 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 03 Jan 2008, 02:21 PM
Hi Per,

Although I am not sure whether I get your idea correctly, I assume that you would like to reference the physical path of your web site root from the code-behind. Is this information correct? If so, you may consider using the Server.MapPath("~/") method of the framework to achieve your goal.

Here is a sample usage of this method:

http://www.telerik.com/demos/aspnet/Grid/Examples/Programming/NeedDataSource/DefaultCS.aspx (see the GetDataTable method definition)

Best,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Per Holmqvist
Top achievements
Rank 2
answered on 03 Jan 2008, 02:30 PM

Hi Steven.

No, that would have been to easy.
If i need to open up an promoteus RAdWindow, i need to do this by javascript.

    function openGBWindow(UserID, Username, GBID, AppRoot)  
        {  
            var oWnd = radopen(approot + "/modules/profile/gb/popgb.aspx?UserID=" +UserID+"&UserName=" +Username+"&GBID="+GBID, "RadWindow1" );  
            oWnd.setSize(600,250);  
            oWnd.Center();  
        } 

But on my developComputer the "~/" is a virtual directory, but on my productionserver it is the correct root.

So what I meen if that ifmy application is called "RootDemo" when set an URL to "~/default.aspx" it became /RootDemo/default.aspx
So what I need/Want is to write out only RootDemo.
Ofcourse i can make a solution with server.Mappath() and slit to array and take the upperbound value, but I think there is a way in NET to get what I want.

Or am I wrong? ;)
0
Per Holmqvist
Top achievements
Rank 2
answered on 03 Jan 2008, 10:32 PM
i found it.. 

Request.ApplicationPath

How do I set this topis as answered?

0
Sebastian
Telerik team
answered on 04 Jan 2008, 08:50 AM
Hello Per,

I am glad that you found the solution by yourself. I will close this thread for you.

Regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
Per Holmqvist
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Per Holmqvist
Top achievements
Rank 2
Share this question
or