views:

312

answers:

2

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.

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.

A: 

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.

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.

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.

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

Jay S
A: 

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

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
Diodeus