473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to hide/show a div?

Hello,

I have an image and a div named "content" in an ASP.Net / VB web page.

I need to create something like an on/off (visible/hidden).

1. When I click the image and the div is visible, the div becomes
hidden.
2. When I click the image and the div is hidden, the div becomes
visible.

So it's only one image controlling the div visibility.

How can I do this?

Thanks,
Miguel

Nov 19 '05 #1
4 25013
Use a Panel and it's Visible Property

--
'dlbjr
'Pleading sagacious indoctrination!
Nov 19 '05 #2
Server side or client side?

On the server, it's easy:
myControl.Visible = true;
myOtherControl.Visible = false;

On the client, it's trickier, but doable:
<script>
// Always test EVERYTHING! Script errors suck.
if (document && document.getElementById)
{
var myControl = document.getElementById("myControl");
var myOtherControl = document.getElementById("myOtherControl");

if (myControl && myOtherControl)
{
myControl.style.visibility = "visible";
myControl.style.position = "relative";

myOtherControl.style.visibility = "hidden";
myOtherControl.style.position = "absolute";
}
}
</script>

Good luck!
Jason
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #3
Hi,

Thanks for the help.

What are the advantages and disadvantages or each approach?

Is server side code the best way?

Thanks,
Miguel

"jasonkester" <ja*********@gmail.com> wrote in message
news:ja*********@gmail.com:
Server side or client side?

On the server, it's easy:
myControl.Visible = true;
myOtherControl.Visible = false;

On the client, it's trickier, but doable:
<script>
// Always test EVERYTHING! Script errors suck.
if (document && document.getElementById)
{
var myControl = document.getElementById("myControl");
var myOtherControl = document.getElementById("myOtherControl");

if (myControl && myOtherControl)
{
myControl.style.visibility = "visible";
myControl.style.position = "relative";

myOtherControl.style.visibility = "hidden";
myOtherControl.style.position = "absolute";
}
}
</script>

Good luck!
Jason
Expat Software Consulting Services
http://www.expatsoftware.com/


Nov 19 '05 #4

"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
Hi,

Thanks for the help.

What are the advantages and disadvantages or each approach?

Is server side code the best way?


It depends, server side code will required a round trip back to the server,
slowing your user experience and adding load to the server but will always
work regardless of the client.

Client side will perform better, but you have the problem of testing to
ensure your client side script works on all browsers, and the knowledge that
it won't work at all if the user has scripting turned off.
--
Rob Labbé, MCP, MCAD, MCSD, MCT
Lead Architect/Trainer
Fidelis

Blog: http://spaces.msn.com/members/roblabbe
Nov 19 '05 #5

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

Similar topics

9
by: Robb Gilmore | last post by:
Hello, This is probably an easy one, but I have not been able to figure it out so far. I have a tab control on a windows forms app. Depending on some business logic, I need to hide/show some...
2
by: Sandra | last post by:
Hello, I want to develop an application for WindowsCE using eMbedded Visual C++ 4.0. Is it possible to add/delete or hide/show toolbars by running the application. e.g. the user choose a menuitem...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
1
by: Norman | last post by:
Hello All, I have developed the ASP.Net application using .Net 1.1. I want to get one section of the page under hide/show feauture. That means when the user clicks on display I want to display all...
2
by: Greg | last post by:
Hello, I am trying to display order ids and order details (order items). I would like to give the user Hide/Show option to either display or hide order details. The page would look like: ...
1
by: roni | last post by:
hi. i have webform with 4 panel that i switch then in wizard style ( asp 1.1) . i want to know if i can hide/show the asp panel control IN THE CLIENT SIDE ? meaning, show panel 1 . user enter...
4
by: =?Utf-8?B?U3JpZGhhcg==?= | last post by:
Hi, Is it possible to Hide/Show controls during a callback? I have a radio button list that does the callback. When it does the callback I need to refresh the grid to reflect the selected value...
6
elamberdor
by: elamberdor | last post by:
Hi All! Trying to get a drop down hide/show div on a html page triggered by a button in flash. (Intro: Very very Little experience in dynamic flash) setup: html page, flash map on page, button...
15
by: worked | last post by:
I have a script that hides / shows form elements, and wrapped in a tab script (tab navigation). When the code is duplicated (per tab content), the hide / show function works for the first tab but...
11
by: dmorand | last post by:
I'm having some trouble with my javascript which is supposed to hide/show a div element. I have to click on the link twice before it'll hide. I can't seem to figure out why the first click does...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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,...
0
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...

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.