Click to See Complete Forum and Search --> : Dynamic Anchors within ASP page


davidbaker29
01-23-2006, 10:43 PM
I am currently building a page that initially displays a list of categories e.g.

Category 1
Category 2
etc

Clicking on a category should cause a list of the items in the category to be shown e.g. clicking Category 1 should lead to:

Category 1
Item 1
Item 2 etc.
Category 2

I have implemented this part successfully. I have placed a hyperlink in each Category so that when it is clicked the page is refreshed, with a parameter 'categoryid' used to return the relevant items from the database.

My problem is that if there are a lot of categories, then clicking on say Category 27 returns the items successfully, but the refreshed page returns to the top, and the user has to scroll down to Category 27 again.

I have tried to add a link to Item 1 when Category 1 is clicked, however this does not work as Item 1 is not yet present on the page when Category 1 is clicked. Item 1 etc get written to the page, but the refreshed page goes back to the top.

I have also tried to add a link to itself (Category 1) when Category 1 is clicked. This simply leaves the page exactly as it is - Item 1 etc. don't get written to the page, since the code follows the link and ignores the later code to write the items to the page.

Any suggestions on how to overcome this will be greatly appreciated.

Thanks

Ubik
01-24-2006, 12:00 PM
Load all parent categories and child categories, then use css to hide/display them when you want.

Or, use AJAX to load the children when a parent is clicked.

Reloading the page each time is hell for the users. Trust me, I was a user where they had five layers of parents/children with several hundred thousand possible combinations and releading each time really sucked. I convinced them to just load them all from the start and go from there. It was on a LAN so bandwidth was not really an issue.

davidbaker29
01-24-2006, 06:05 PM
Hi, thanks for your reply. I am new to ASP so I'm not sure how to go about implementing your suggestion. Do you mean that I should write everything to the page when it first loads but that I can hide some of the tables or table rows? By css do you mean using a style sheet? Do you have any sample code to show what you mean? Thanks again

Bullschmidt
01-29-2006, 05:43 PM
For a related link to show everything but in a nice format where each category name is shown above all the items in that category:

Classic ASP Design Tips - Grouping Data
http://www.bullschmidt.com/devtip-groupdata.asp