Apr
01
2009
When in need of a quick way to expand and collapse HTML code on the client without posting back to the server of your web application, utilize the <div> tag with a style and some Javascript. Start with the style display set to either none or block and then interchange these two setting based upon a hyperlink click event.
<a href="javascript:;" onmousedown="if(document.getElementById('divMessage_1').style.display == 'none')
{ document.getElementById('divMessage_1').style.display = 'block'; }
else{ document.getElementById('divMessage_1').style.display = 'none'; }">Show/Hide</a>
<div id="divMessage_1" style="display:none">
<p>This is something to show or hide.</p>
</div>