473,698 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ 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="DefaultMa ster.css" rel="stylesheet " type="text/css" />
<script type="text/javascript" language="javas cript"><!--
function toggleVisibilit y (elementID) {
var element = document.getEle mentById(elemen tID);
if (element.style. display != "block") {
element.style.d isplay = "block";
} else {
element.style.d isplay = "none";
}
}
//--></script>
</head>
<body>
<form id="form1" runat="server">

<div id="sidebar">
<div class="menuItem ">
<span class="itemHead er" onclick="toggle Visibility('web Apps');">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
Web Applications
</span>
</div>
<div id="webApps" class="subMenuG roup">
<div class="subMenuI tem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
<a href="Page1.asp x">Page 1</a>
</div>
<div class="subMenuI tem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
<a href="Page2.asp x">Page 2</a>
</div>
</div>
</div>
<div id="content">
<asp:contentpla ceholder id="mainContent Holder" runat="server">
<!-- My content -->
</asp:contentplac eholder>
</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 2618
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="DefaultMa ster.css" rel="stylesheet " type="text/css" />
<script type="text/javascript" language="javas cript"><!--
function toggleVisibilit y (elementID) {
var element = document.getEle mentById(elemen tID);
if (element.style. display != "block") {
element.style.d isplay = "block";
} else {
element.style.d isplay = "none";
}
}
//--></script>
</head>
<body>
<form id="form1" runat="server">

<div id="sidebar">
<div class="menuItem ">
<span class="itemHead er" onclick="toggle Visibility('web Apps');">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
Web Applications
</span>
</div>
<div id="webApps" class="subMenuG roup">
<div class="subMenuI tem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
<a href="Page1.asp x">Page 1</a>
</div>
<div class="subMenuI tem">
<img src="<%= Page.ResolveUrl ("~/images/arrowsmall.gif" ) %>"
alt="Arrow" />
<a href="Page2.asp x">Page 2</a>
</div>
</div>
</div>
<div id="content">
<asp:contentpla ceholder id="mainContent Holder" runat="server">
<!-- My content -->
</asp:contentplac eholder>
</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
1510
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 the development work on my own computer running IIS with, of course, PHP and MySQL installed. When the site is operational (at a hosting site yet to be determined), I will need to periodically (every few days) add and delete records in the database....
3
3459
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 details. I have nav Link buttons that allow you to go to previous or next object from the object list on previous page. In the command event of the linkbutton, the page is redrawn with the details of the next or previous object. I am using...
1
1547
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. How to maintain the scrolled position in the web form. 2. I made the following changes in web.config file. <configuration> <system.web> <pages smartNavigation = "true"/> </system.web>
7
2033
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 Button1.Click Response.Redirect("login.aspx") End Sub Very simple. Forget what login.aspx does, it's just somewhere to redirect to.
1
1273
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 Google handles the pagination when a lot of pages are returned. That is: If you are at page 1 of 100 possible pages, you want to see the following:
7
10346
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 hierarchy of the menu tree. All pretty normal stuff. Is there any simple method of maintaining the expanded / collapsed state of each node as my application moves from page to page? Remember this is on a master page used by numerous content...
1
7643
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 ParseWordDoc(ByVal Filename As String) As String Dim sNewFileName As String Dim WordApp As Word.Application = New Word.Application Dim BaseDoc As Word.Document Dim DestDoc As Word.Document
0
1283
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 showhide(). I would like to maintain the block's display state when the page is posted back. I'm having difficulties to retrieve the div style attributes from the viewstate: Me.divProdCat.Style.Item("display") always returns the same attribute.
1
1510
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 if it is longer than the width of the control. This data will later be taken from this control and put into a text box in a report in ReportViewer where I will want to preserve the same formating there. Thank you,
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9023
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7721
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.