Simple Java Script question Re ApplicationPath

R

Radu

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 the code:

<script language="javascript">
function previewFile(cbo)
{
var index = cbo.selectedIndex;
var ifr = document.getElementById('<%=frameDocPreview.ClientID
%>');
var hLink = document.getElementById('<%=cmdOpenPreview.ClientID
%>');
var hLinkBW = document.getElementById('<%=cmdSupporting.ClientID
%>');

// first item is ' please select...'
if (index > 0)
{
ifr.src = 'preview.aspx?file=' +
escape(cbo.options[index].text);
hLink.href='<%=request.ApplicationPath %>'+ "/Previews/"+
cbo.options[index].text + ".doc";
hLinkBW.href='<%=request.ApplicationPath %>'+ "/BW Previews/"+
cbo.options[index].text + ".doc"
}
else
{
ifr.src = "#";
hLink.href="#";
hLinkBW.href="#"
}
document.getElementById('cmdNextPage').focus;
}
</script>


The hyperlinks themselves are defined in that page as:

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

and

<asp:HyperLink
ID="cmdSupporting"
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 1 - SelectScorecard.aspx#
to
http://scorecard previews/Operations.doc
thus, obviously, missing the ApplicationPath part, as opposed to the
instance on my machine, which reads
http://localhost:1218/Ordering Process/Scorecard Previews/Us 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.ApplicationPath %>'+ "/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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top