473,563 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Java Script question Re ApplicationPath

Hi. I have a page, named "SelectScorecar d", which contains a combo
and some links to outside documents, on the server. These documents
are situated in some sub-folders of the webfolder, named "Previews"
and "BW Previews". On selection of an item in the combo, the HREF of
those links has to change.

In the SelectScorecard .aspx page, I have the code:

<script language="javas cript">
function previewFile(cbo )
{
var index = cbo.selectedInd ex;
var ifr = document.getEle mentById('<%=fr ameDocPreview.C lientID
%>');
var hLink = document.getEle mentById('<%=cm dOpenPreview.Cl ientID
%>');
var hLinkBW = document.getEle mentById('<%=cm dSupporting.Cli entID
%>');

// first item is ' please select...'
if (index 0)
{
ifr.src = 'preview.aspx?f ile=' +
escape(cbo.opti ons[index].text);
hLink.href='<%= request.Applica tionPath %>'+ "/Previews/"+
cbo.options[index].text + ".doc";
hLinkBW.href='< %=request.Appli cationPath %>'+ "/BW Previews/"+
cbo.options[index].text + ".doc"
}
else
{
ifr.src = "#";
hLink.href="#";
hLinkBW.href="# "
}
document.getEle mentById('cmdNe xtPage').focus;
}
</script>
The hyperlinks themselves are defined in that page as:

<asp:HyperLin k
ID="cmdOpenPrev iew"
Font-Size="11px"
Target="_blank"
Text="here"
runat="server">
</asp:HyperLink>

and

<asp:HyperLin k
ID="cmdSupporti ng"
Font-Size="11px"
Target="_blank"
Text="here"
runat="server">
</asp:HyperLink>

The problem is that it works great on my machine.... On the DEV
server, though, upon selection of an item in the combo, HREF goes from
http://uat.mysite.com/Step%201%20-%2...corecard.aspx#
to
http://scorecard%20previews/Operations.doc
thus, obviously, missing the ApplicationPath part, as opposed to the
instance on my machine, which reads
http://localhost:1218/Ordering%20Pro...Operations.doc
which correctly points to the app path in addition to the "Previews"
folder and the selected (in this case, "US Operations") document.

So.... What's wrong with my script, saying
hLink.href='<%= request.Applica tionPath %>'+ "/Previews/"+
cbo.options[index].text + ".doc";

On the server, it picks up only the
"/Previews/"+ cbo.options[index].text + ".doc"
part, whereas on my dev machine it works great.

Thanks a lot for your reading this post.
Alex.

Apr 26 '07 #1
1 4518
Try ResolveUrl ("~") instead of ApplicationPath .

"Radu" wrote:
Hi. I have a page, named "SelectScorecar d", which contains a combo
and some links to outside documents, on the server. These documents
are situated in some sub-folders of the webfolder, named "Previews"
and "BW Previews". On selection of an item in the combo, the HREF of
those links has to change.

In the SelectScorecard .aspx page, I have the code:

<script language="javas cript">
function previewFile(cbo )
{
var index = cbo.selectedInd ex;
var ifr = document.getEle mentById('<%=fr ameDocPreview.C lientID
%>');
var hLink = document.getEle mentById('<%=cm dOpenPreview.Cl ientID
%>');
var hLinkBW = document.getEle mentById('<%=cm dSupporting.Cli entID
%>');

// first item is ' please select...'
if (index 0)
{
ifr.src = 'preview.aspx?f ile=' +
escape(cbo.opti ons[index].text);
hLink.href='<%= request.Applica tionPath %>'+ "/Previews/"+
cbo.options[index].text + ".doc";
hLinkBW.href='< %=request.Appli cationPath %>'+ "/BW Previews/"+
cbo.options[index].text + ".doc"
}
else
{
ifr.src = "#";
hLink.href="#";
hLinkBW.href="# "
}
document.getEle mentById('cmdNe xtPage').focus;
}
</script>
The hyperlinks themselves are defined in that page as:

<asp:HyperLin k
ID="cmdOpenPrev iew"
Font-Size="11px"
Target="_blank"
Text="here"
runat="server">
</asp:HyperLink>

and

<asp:HyperLin k
ID="cmdSupporti ng"
Font-Size="11px"
Target="_blank"
Text="here"
runat="server">
</asp:HyperLink>

The problem is that it works great on my machine.... On the DEV
server, though, upon selection of an item in the combo, HREF goes from
http://uat.mysite.com/Step%201%20-%2...corecard.aspx#
to
http://scorecard%20previews/Operations.doc
thus, obviously, missing the ApplicationPath part, as opposed to the
instance on my machine, which reads
http://localhost:1218/Ordering%20Pro...Operations.doc
which correctly points to the app path in addition to the "Previews"
folder and the selected (in this case, "US Operations") document.

So.... What's wrong with my script, saying
hLink.href='<%= request.Applica tionPath %>'+ "/Previews/"+
cbo.options[index].text + ".doc";

On the server, it picks up only the
"/Previews/"+ cbo.options[index].text + ".doc"
part, whereas on my dev machine it works great.

Thanks a lot for your reading this post.
Alex.

Apr 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6566
by: Stefan Poehn | last post by:
Hi does anybody know a tool that converts Java-Code to C++? I need a very simple converter that does NOT need to cover Threading, Swing, Exceptions, Reflection, RMI, Security, Networking and most of java.util (except LinkedList). It also does not need to cover garbage collection (new is not allowed in the java code that should be...
5
2380
by: Vadym Stetsyak | last post by:
Hi, All! For example if I have http://server/myvirtualpath/someotherpath/page.asp and virtual path on the IIS is http://server/myvirtualpath How can I retrieve above mentioned asp application path. I need the same functionality that has ASP.NET (Request.ApplicationPath)
2
3804
by: martin | last post by:
Hi, I am developing a class to help my asp.net application along. The class is part of a seperate project although this project is included in the same solution as my main web application. I wish to use the function "request.applicationpath" from inside my class. In solution explorer I have right clicked on the references node and...
8
8481
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there a way to get it from a static method in an aspx page, or in the class (static) constructor for an aspx page? Thanks, Bryan
4
1470
by: Brian Henry | last post by:
I have an XML file formated as this <?xml version="1.0" encoding="utf-8" ?> <settings> <databaseServer>Dell5100</databaseServer> <defaultDatabase>bene</defaultDatabase> </settings> relateively simple file... I want to be able to say which attribute of the settings group I want to read in a settings read function and return it...
73
4561
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an endless loop in a line with: if a==b: print 'OK' I mean, it would be of much help to me on my way to understanding Python to know how such prefix...
7
443
by: imatts | last post by:
Hi can anyone help with this little problem. I have a simple script to swap between two divs on a page. It works perfectly in Firefox & Safari & Opera. It fails in IE 6 giving Object Required error on initializing second variable var layer2. I can't get to the bottom of this. Can anyone help? <script type="text/javascript"> function...
1
1287
by: Radu | last post by:
Hi. I have a page, named "SelectScorecard", which contains a combo and some links to outside documents, on the server. These documents are situated in some sub-folders of the webfolder, named "Previews" and "BW Previews". On selection of an item in the combo, the HREF of those links has to change. In the SelectScorecard.aspx page, I have...
2
3604
by: CKKwan | last post by:
Dear All, Using VS2008 on Vista (IIS7). Request.ApplicationPath return something like "http://localhost:50440/" When deploy into Server 2003 (IIS6), found that Request.ApplicationPath is returning "c:\\Inetpub\..." May I know what has gone wrong?
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.