469,323 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

script to hide a control

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

May 25 '07 #1
2 7427
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.

May 25 '07 #2
Perfect. Thank you.

On May 25, 7:27 am, Jeff Johns <phpf...@gmail.comwrote:
On May 25, 9:13 am, billsahi...@yahoo.com wrote:
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:
May 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Cathryn Lindner | last post: by
3 posts views Thread by sklett | last post: by
12 posts views Thread by mantrid | last post: by
3 posts views Thread by traceable1 | last post: by
14 posts views Thread by asdf | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.