Div Tag

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
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!!!!!!!!
 
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
 
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">
 
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.
 
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
 
use this
<div id="MyDivTag" style="visibility:hidden"></div>
and
to make it visible
<div id="MyDivTag" style="visibility:visible"></div>
 
Back
Top