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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP navbar in table - can you refresh a portion of the page?

Status
Not open for further replies.

CFB

Programmer
Jan 11, 2001
74
US
Let me see if I can explain what I'm doing. I've got a header.asp for my banner, a navbar.asp for my navigation bar, and a template.asp which I created as a base for all my pages. The template.asp creates a large table on the page with the top row containing <!-- #include virtual=header.asp&quot;-->, the left most column in the second row containing <!-- #include virtual=navbar.asp&quot;-->, and the right hand column in the second row contains my different pages. I did this to avoid using frames.

In my navbar I have a tree type view which I created with a small jscript function and a few <DIV> tags. Each time you click on an item the tree expands showing you links to other pages. When you click a link to another page the navbar.asp and header.asp reload when the new page loads. Since everything is reloading, the item in the navbar that had the tree view expanded is now set back to it's original collapsed state.

My question is, is it possible to only refresh the the <TD></TD> that is holding all of my page contents and not refresh the navbar.asp or header.asp? Doesn't sound possible, but I had to ask. Or would a better approach be to somehow call my navbar.asp page again to refresh it's expanded view?

Hopefully my question makes sense... Sorry for the long post and thanks for the help.
-CFB
 
if you keep cycling thru template.asp with different querystring params (or something) so the page knows to display different content, why not make the navbar script take note of the querystring to decide it's initial state. codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
I would agree with codestorm. You can't actually refresh a portion of a table instead of the whole page, but taking note of the state (perhaps assign node id's) and opening the tree up to the link that was clicked will work.
Another option is to create a binary string that stands for the state of the tree, and then passing that to the next page. While this is not as easy, it means that not only will the link they clicked on still be exapnded, but anything thewy had expanded could be expanded on page load to give the user the illusion of not having changed pages.
Here is how it would work:
On Submit call evalTree

Code:
evalTree()
   frmForm.hdnTreeState.Value = evalNode(rootNode)

evalNode(node)
    var myBinStr
    1) If I am Null, return empty string
    2) If I am Closed, 
         concatenate a 0 to myBinStr
    2) If I am open
         concatenate a 1 to myBinStr
         For i = 0 to numMyChildren
            myBinStr += evalNode(children(i))
         Next
    3) return myBinStr

Another way to do this would be to just assign each node a incrememntal id ad loop through them adding a 0 or 1 to state, then on next page loop through again to decide initial state.
-Tarwn


------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
All very intersting ideas, especially passing the binary string. Now I'm new to ASP, JScript, and Web type dev in general (5 days to be exact), so bear with me. I've created a tree using <DIV> tags and each <DIV> tag has an ID. I build these tags dynamically based on query results in the database, so their <DIV ID> value changes each time the page refreshes. I get the collasped look for my tree nodes by manipulating the .style.display value (basically turning it on and off), so checking it's state would be easy. Since the tree values aren't static, how would I go about cycling through all of them so I could check their state?

In order for me to pass a parameter to a page that I've referenced with an ASP #include I need to do what? In other words, do you guys know the syntax for doing something like that?

One last question. Since I'm new to this, does the approach I'm taking regarding the header.asp, navbar.asp, and the way I've created the treeview seem like the best solution? Hope I'm not boring you with stupid questions. Thanks.
-CFB
 
In regards to cycling through them, you could do this with specifying the id for the head node, than instead of using an incremental id name for getting the children you could use the children(number) attribute to get the children objects.

In regards to passing values to a #include. Since the #include is processed before the ASP script begins being processed, any variables you define in your program before the #include can be reused inside the file that is included and they should have the same value. I often dop this with my database connections if I need it in a great number of files, I dim my strCOnnect variable than include the file that has strConnect = &quot;my connection string&quot; so I can keep the connection string in one location.

In regards to direction, Yes. Often the header will in either an include file in html or an asp function in an ASP include file, this means changes only need to occur in a single location rather than multiple locations. The only way I create tree divs is with indented divs similar to the one found in the standard IE xsl sheet for displaying xml files. My nodes generally look like:
Code:
<div class=&quot;node&quot;>
   <div class=&quot;symbol&quot;>+</div>
   <div class=&quot;contents&quot;> Contents, can be more nodes or just text or whatever </div>
</div>
I start out with the contents class being display:none; and redirect the onCLick event for the node, symbol, contents to return a reference to the node. Then all I need to do to open/close it is change the contents of clickedNode.children(0) and change the display of clickedNode.children(1).style.display to none or visible depending on the value I just changed the symbol to (children(0)). Treeviews can be fun, but a little advanced to start with.
Sorry for the ramble, sometimes I just can't stop talking :p
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top