473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Maintain div display between pages

Hello there,

I have an interesting problem to takle. I'm creating a website that's
going to be run in a local Intranet. The site uses a MasterPage /
content page scheme, with the Master page defining a "sidebar" area
that contains links to pages, and the content for those pages being
displayed in a single content area.

The sidebar is divided up into sections, that are show/hidden without
postbacks using javascript. Here's an example:

<head runat="server">
<title>My Page</title>
<link href="DefaultMaster.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript"><!--
function toggleVisibility (elementID) {
var element = document.getElementById(elementID);
if (element.style.display != "block") {
element.style.display = "block";
} else {
element.style.display = "none";
}
}
//--></script>
</head>
<body>
<form id="form1" runat="server">

<div id="sidebar">
<div class="menuItem">
<span class="itemHeader" onclick="toggleVisibility('webApps');">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
Web Applications
</span>
</div>
<div id="webApps" class="subMenuGroup">
<div class="subMenuItem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
<a href="Page1.aspx">Page 1</a>
</div>
<div class="subMenuItem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
<a href="Page2.aspx">Page 2</a>
</div>
</div>
</div>
<div id="content">
<asp:contentplaceholder id="mainContentHolder" runat="server">
<!-- My content -->
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

Of course, a problem occurs when a user actually clicks a link (or
triggers a postback on a page). The "display" property of my sidebar
items gets lost and set back to its default value (i.e. none). I have
a few ideas about how I could handle this problem for the postback
case, but I'm not sure about going across pages. Does any one have any
suggestions?

Thanks,
Evan

Mar 26 '07 #1
2 2589
your javascript can maintain state in a hidden field. if you keep it
small, you can append it to the links when clicked or store it in a cookie.

-- bruce (sqlwork.com)

Evan M. wrote:
Hello there,

I have an interesting problem to takle. I'm creating a website that's
going to be run in a local Intranet. The site uses a MasterPage /
content page scheme, with the Master page defining a "sidebar" area
that contains links to pages, and the content for those pages being
displayed in a single content area.

The sidebar is divided up into sections, that are show/hidden without
postbacks using javascript. Here's an example:

<head runat="server">
<title>My Page</title>
<link href="DefaultMaster.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript"><!--
function toggleVisibility (elementID) {
var element = document.getElementById(elementID);
if (element.style.display != "block") {
element.style.display = "block";
} else {
element.style.display = "none";
}
}
//--></script>
</head>
<body>
<form id="form1" runat="server">

<div id="sidebar">
<div class="menuItem">
<span class="itemHeader" onclick="toggleVisibility('webApps');">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
Web Applications
</span>
</div>
<div id="webApps" class="subMenuGroup">
<div class="subMenuItem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
<a href="Page1.aspx">Page 1</a>
</div>
<div class="subMenuItem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif") %>"
alt="Arrow" />
<a href="Page2.aspx">Page 2</a>
</div>
</div>
</div>
<div id="content">
<asp:contentplaceholder id="mainContentHolder" runat="server">
<!-- My content -->
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

Of course, a problem occurs when a user actually clicks a link (or
triggers a postback on a page). The "display" property of my sidebar
items gets lost and set back to its default value (i.e. none). I have
a few ideas about how I could handle this problem for the postback
case, but I'm not sure about going across pages. Does any one have any
suggestions?

Thanks,
Evan
Mar 26 '07 #2
On Mar 26, 9:49 pm, bruce barker <nos...@nospam.comwrote:
your javascript can maintain state in a hidden field. if you keep it
small, you can append it to the links when clicked or store it in a cookie.
Or stuff it into the ViewState of the Page object...

--
http://ajaxwidgets.com
ASP.NET 2.0 Ajax Widgets

Mar 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Martin | last post by:
Newbie question: What's the "proper" way for me as a site administrator to add and delete records in a MySQL database? I'm developing a web site that will be using PHP and MySQL. I'm doing...
3
by: | last post by:
This is a very open ended question. I have an app with a page that uses link buttons to change the display. On the prior page you have a list of objects. You click one of those objects to see it's...
1
by: Smith John | last post by:
I am developing web based application using ASP.Net. When the user clicks on the last button in the screen(scrolled down screen), screen postback happens, and display at the start of the page. 1....
7
by: Tom wilson | last post by:
I have created a very simple example that doesn't work. Form1 contains a textbox and a button: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
1
by: Henrik | last post by:
Hello all. I'm after some sort of pagination function. One that takes some in data that I provide, and returns an array of controls, pointing to page 2, page 3 etc. Trying to mimic the way that...
7
by: Andrew Robinson | last post by:
I have a treeview control that I use as a menu & navigation control within a master page. The nodes for this control are loaded from a database which contains the text and url of each like and the...
1
by: Adam Faulkner via DotNetMonster.com | last post by:
I had a problem before extracting pages from an existing word document and then inserting the content into a new word document. The following code below works with Microsoft Word 2000 Function...
0
by: msch-prv | last post by:
How to maintain the display state of a <divelement? Is there a simple way to maintain the display state of a <div> element? On my page, a div block can be hidden/shown by js function...
1
by: dbuchanan | last post by:
I want to fill a textbox or a label or with lines from a listbox. I want to preserve the lline for line as it comes from the list box. I do not want the test to run-on. I suppose it is okay to wrap...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.