我可以替换ASP(Classic)中的内容吗?

时间:2022-07-29 01:55:33

Say I have "default" content on the left side of my application, which is included in a header page: a search box and a login box. If the user is on the search page, I want to also add a list of search filters (e.g. brand, price) to the left side of the page; in this case the left side needs to access the parameters given to the search (e.g. keyword search for "black leather chair"); I build up a rather complex query on the search page, search.asp, and I'd rather not have to duplicate it with some kind of giant If..Then statement on the left content page as well.

假设我的应用程序左侧有“默认”内容,它包含在标题页中:搜索框和登录框。如果用户在搜索页面上,我还想在页面左侧添加搜索过滤器列表(例如品牌,价格);在这种情况下,左侧需要访问给予搜索的参数(例如,关键字搜索“黑色皮椅”);我在搜索页面search.asp上构建了一个相当复杂的查询,而且我不必在左侧内容页面上使用某种巨大的If..Then语句复制它。

Is there a way to do this and "append" additional content to a file that's already been included in the page? Basically something like content_for in Ruby on Rails, where I can say on this page, add these things to the <div id="left"> node. I'm not really an expert on Classic ASP (and I'd rather not be using it, truth be told) but my boss wants filters on the left side of the page only for the search page, along with the login/search boxes (that also appear on ALL pages) and I'm not sure how to handle it like this without having to restructure the entire page.

有没有办法做到这一点并“附加”其他内容到已经包含在页面中的文件?基本上类似于Ruby on Rails中的content_for,我可以在这个页面上说,将这些东西添加到

节点。我真的不是经典ASP的专家(而且我宁愿不使用它,事实上要说实话)但是我的老板想要在页面左侧只为搜索页面提供过滤器,以及登录/搜索框(也出现在所有页面上)我不知道如何处理它而不必重新整理整个页面。

3 个解决方案

#1


In ASP you can grab the current path and file with this:

在ASP中,您可以使用以下方法获取当前路径和文件:

pagePath = Request.ServerVariables("PATH_INFO")

You can split the string, grab the last element. So a select case and spit out the appropriate content based on the file name:

你可以拆分字符串,抓住最后一个元素。所以选择一个案例并根据文件名吐出适当的内容:

select case pageName

case "search.asp"
   ...
case "products.asp"
   ...
case else
   ...
end select

#2


You could easily set up a div on the left hand side with the content you want and then toggle the visibility of the DIV using client-side javascript.

您可以在左侧轻松设置所需内容的div,然后使用客户端javascript切换DIV的可见性。

Your javascript could check current location and if it falls within a list of pages it wants the section to display for (in case you build another search page), toggle the visibility to true.

您的javascript可以检查当前位置,如果它属于要显示该部分的页面列表(如果您构建另一个搜索页面),则将可见性切换为true。

If you'd rather not render the HTML on the left-side at all, you could dynamically write the HTML to the DIV using Javascript.

如果你不想在左侧渲染HTML,你可以使用Javascript动态地将HTML写入DIV。

Alternatively, you could set up a DIV in your search page and use CSS to align it to the left of the page.

或者,您可以在搜索页面中设置DIV,并使用CSS将其与页面左侧对齐。

#3


Any include can use variables collected in previous functions. For example if you retrieve your search keywords before anything else, then you can update values in any code that appears later, even in include files because those includes are after all just more code that it is included in the whole of the page, except that it has been included on an insert because it may be common to other pages.

任何include都可以使用以前函数中收集的变量。例如,如果您在其他任何内容之前检索搜索关键字,那么您可以更新稍后出现的任何代码中的值,即使在包含文件中也是如此,因为这些包含的内容只是包含在整个页面中的更多代码,除了它已包含在插入内容中,因为它可能与其他页面相同。

Or you can run functions to process those variables, such as find related results.

或者,您可以运行函数来处理这些变量,例如查找相关结果。

#1


In ASP you can grab the current path and file with this:

在ASP中,您可以使用以下方法获取当前路径和文件:

pagePath = Request.ServerVariables("PATH_INFO")

You can split the string, grab the last element. So a select case and spit out the appropriate content based on the file name:

你可以拆分字符串,抓住最后一个元素。所以选择一个案例并根据文件名吐出适当的内容:

select case pageName

case "search.asp"
   ...
case "products.asp"
   ...
case else
   ...
end select

#2


You could easily set up a div on the left hand side with the content you want and then toggle the visibility of the DIV using client-side javascript.

您可以在左侧轻松设置所需内容的div,然后使用客户端javascript切换DIV的可见性。

Your javascript could check current location and if it falls within a list of pages it wants the section to display for (in case you build another search page), toggle the visibility to true.

您的javascript可以检查当前位置,如果它属于要显示该部分的页面列表(如果您构建另一个搜索页面),则将可见性切换为true。

If you'd rather not render the HTML on the left-side at all, you could dynamically write the HTML to the DIV using Javascript.

如果你不想在左侧渲染HTML,你可以使用Javascript动态地将HTML写入DIV。

Alternatively, you could set up a DIV in your search page and use CSS to align it to the left of the page.

或者,您可以在搜索页面中设置DIV,并使用CSS将其与页面左侧对齐。

#3


Any include can use variables collected in previous functions. For example if you retrieve your search keywords before anything else, then you can update values in any code that appears later, even in include files because those includes are after all just more code that it is included in the whole of the page, except that it has been included on an insert because it may be common to other pages.

任何include都可以使用以前函数中收集的变量。例如,如果您在其他任何内容之前检索搜索关键字,那么您可以更新稍后出现的任何代码中的值,即使在包含文件中也是如此,因为这些包含的内容只是包含在整个页面中的更多代码,除了它已包含在插入内容中,因为它可能与其他页面相同。

Or you can run functions to process those variables, such as find related results.

或者,您可以运行函数来处理这些变量,例如查找相关结果。