Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the content in a div from a menu

Status
Not open for further replies.

baggen

Technical User
Aug 18, 2007
6
0
0
SE
Hi everybody!
I'm working on a site, written in CSS and ASP.
Issue: I have this CSS-page. In this page I have a menu. Here's the code:
<div id="left">
<div id="sub_left">
<div class="navcontainer">
<ul class="navlist">
<li><a href="#">Test1</a></li>
<li><a href="#">Test2</a></li>
<li><a href="#">Test3</a></li>
<li><a href="#">Test10</a></li>
<li><a href="#">Test20</a></li>
<li><a href="Test30.asp" target="_top">Test30</a></li>
</ul>
</div>


When I click on Test1, I want to show the content of a html or an asp-page in a div called main_content (<div id="main_content">). When I click on Test2, I want to show some other text from another html-page in the same div, but the content from Test1 should be removed.
Can this be done by using "include file"?
Please let me know if I'm indistinct.
/Paul
 
You can also use an iframe in that main content div, name it, and use it as target on thos links. Only problem is that if the content is big enought it might scroll the iframe.
Or you can use javascript and Ajax as Spork52 mentioned.

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Thanks for the respons. Right now it seems that the best way to solve this problem is by using AJAX. I have never tryed this before, so it's gonna be interesting :)
 
I know I sent you here, but I'm going to have to go against thew suggestions given. They just seem so convoluted, when all it really would take would be an include call.

Now I'm not ASP expert, but i'm sure ASP can display an included file based on a clicked link.

Assuming your links look like:

<a href="index.asp?contentoload=x">
<a href="index.asp?contentoload=y">
<a href="index.asp?contentoload=z">

Where x,y,z is either the file that holds the contents of the div, or maybe just an identifier, i would assume you can just use an if construct to call up the proper file to be displayed.







----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Using includes would require reloading the page. Or you could use the ASP version of XMLHTTP to pull in html files, but that would also require reloading. If you are going to do either of those then why not just have different pages for different content?

Besides, unlike PHP, includes in ASP are NOT dynamic. You would have to set up a case statement to pick out which include to actually display. Not a good way to code: The ASP server loads ALL the includes first and then processes the case statement in the VBScript. Quickly become unwieldy if there is a lot of content to choose from.
 
Well then I see its not as straight forward in ASP as I thought it would be.

Perhaps reading the files directly instead of including them?

If you are going to do either of those then why not just have different pages for different content?

I would think its easier to maintain a single page that has headers and menus etc.. than it is to maintain 10 different ones. When you need to make a change to the menu its more practical to change only one file than 10 or 15. As you say it would quickly become unwieldy.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top