Div Tag

J

Jim Heavey

If I use a Div tag to hide/unhide a block of controls, how exactly do I
turn it on and off in code?

<div id="MyDivTag" style="display:'none';"></div>

I am unsure of what the code would look like to toggle the value. Don't I
need a "runat=server" as well on this div tag?

Thanks in advance for your assistance!!!!!!!!
 
G

Guest

Hi Jim

I use something like this on most of my applications, however I tend to use JavaScript as it saves trips to and from the server

Simply attach an onclick event to a button, and depending on the state of the div, make the display to none | block

HTH
 
G

Guest

Whoops

Forgot to add some sample code...

<script language="javascript" id="clientEventHandlersJS"><!-

function imgThreadChevron_onclick()
if(divMessageThread.style.display=="none"

divMessageThread.style.display="block
Form1.imgThreadChevron.src="images/styles/default/chevronDown.gif
Form1.imgThreadChevron.title="Click here to close the message thread."

els

divMessageThread.style.display="none
Form1.imgThreadChevron.src="images/styles/default/chevronUp.gif
Form1.imgThreadChevron.title="Click here to expand the message thread.



//--></script

and for the image button I use..

<IMG language="javascript" id="imgThreadChevron" title="Click here to expand the message thread." style="CURSOR: hand" onclick="return imgThreadChevron_onclick()" src="images/styles/default/chevronUp.gif" align="absMiddle">
 
J

Jim Heavey

Thanks for the code it will come in handy on other projects, but this
project, I need to set the on and off in code. It is not triggered by a a
user action. So I really need an example of setting it in code.
 
V

vMike

put a runat="server" in your div tag on your page


in you code
Imports System.Web.UI.HtmlControls

dim MyDivTag as htmlgenericcontrol
then
MyDivTag.visible true|false
 
G

Gibs

use this
<div id="MyDivTag" style="visibility:hidden"></div>
and
to make it visible
<div id="MyDivTag" style="visibility:visible"></div>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,371
Latest member
TroyHursey

Latest Threads

Top