0

この質問が別の場所で回答されている場合は申し訳ありませんが、いくつかのページを検索してみましたが、うまくいきませんでした。

だから私はすべてのページで使用しているインクルード ファイル (サイドバー) を持っています。

Default.asp
Products.asp
Salary/Survey.asp
inc/sidebar.asp (this is the included file)

sidebar.asp、私はへのリンクを持っていますSalary/Survey.asp

ルートレベルの他のすべてのページから、私は簡単に使用でき、href='Salary/Survey.asp'正常に動作します。しかし、私がページにいるときSurvey.asp、書き込みhref='Salary/Survey.asp'は実際になりSalary/Salary/Survey.aspます。適切に使用する必要があることは理解してい../Salary/Survey.aspますが、ルート レベルのページでは機能しません。

他の誰かのプロジェクトで働いていて、彼のディレクトリ構造がわからないため、パスのオプションしかroot relativeあり/Default.aspません。/Salary/Survey.aspdocument relative

これが理解しやすく、誰かが私を助けてくれることを願っています。

ありがとう!

4

3 に答える 3

2

We solved this problem the following way...

  1. Each of our asp pages included a special file that Dims and sets golbal variables. We called ours Info.asp
  2. Inside Info.asp we defined a variable called strRelativePath
    Dim strRelativePath
    strRelativePath = ""
  3. Every asp page set the relative path according to it relative position:

for example:

  • Root pages - strRelativePath = ""
  • One level deep pages - strRelativePath = "../"
  • Two levels deep pages - strRelativePath = "../../"

Then it was a matter of prefacing all the links requiring a relative path with <%=strRelativePath%>

于 2012-03-31T13:41:02.217 に答える
1
you need to get write this after the that - Salary/Survey.asp
You can get the virtual path to the file from one of several server variables - try either:

Request.ServerVariables("PATH_INFO")
Request.ServerVariables("SCRIPT_NAME")

どちらのサーバー変数も、サブディレクトリとファイル名を含む仮想パスを提供します-例を考えると、/virtual_directory/subdirectory/file.asp. 仮想ディレクトリだけが必要な場合は、次のように、パスからディレクトリを抽出するために好みの方法を使用して、2 番目のスラッシュの後のすべてを削除する必要があります。

s = Request.ServerVariables("SCRIPT_NAME")
i = InStr(2, s, "/")
If i > 0 Then
    s = Left(s, i - 1)
End If
or:

s = "/" & Split(Request.ServerVariables("SCRIPT_NAME"), "/")(1)
于 2012-03-31T18:33:51.570 に答える
0

基本的に、サイドバーを別のフォルダーのプログラムから含めることができる場合、唯一の「簡単な」方法は、言及したように絶対パスを使用することです。

使えないということなので、色々と考えてみます。

  • 仮想フォルダ: IIS では、「給与」の給与フォルダに仮想フォルダを設定し、それをサイトのルートに向けることができました。
  • OS リンク (上記と同様ですが、OS レベルで)
  • マップパスを使用します。mappath をチェックして、自分がいる実際のフォルダーを確認し、正しいインクルード (/salary あり/なし) を使用できますが、これによりエラーが発生する可能性があると思いますが、わかりません。
于 2012-03-23T17:30:34.223 に答える