On May 25, 9:13 am, billsahi...@yahoo.com wrote:
I have an asp.net page that dynamically generates client-side
javascript. What javascript would hide a control? Specifically, I have
a composite web server control and when the user clicks a button a
postback occurs and the asp code sets the control's visible property
to false, so when the html is sent back, the control is not visible.
Is there a way to do that in javascript and avoid the postback? Second
question: what is a good book or resource that covers such javascript
topics?
bill
There are a few ways to show/hide things in javascript which typically
involved setting the style attributes of an element.
visibility: hidden || visible
display: none || (block || inline)
Simple example:
HTML
-----------
<div id="test">This is a test</div>
<a href="#" onclick="toggle('test');">Toggle It</a>
JavaScript
-----------
function toggle(obj)
{
obj = document.getElementById(obj);
if (obj) {
obj.style.display = (obj.style.display != 'none') ? 'none' :
'block';
}
}
A good reference:
http://developer.mozilla.org/en/docs/JavaScript
Hope that helps a bit.