471,881 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,881 software developers and data experts.

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 7469
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
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.