×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to show or hide controls using checkbox click, client-side?

How to show or hide controls using checkbox click, client-side?

How to show or hide controls using checkbox click, client-side?

(OP)
I have separate snippets of text which I want joined together to form an email message. My ASP.net page has a radiobuttonlist where the user can select the email circumstance, and based on the selection I want some checkboxes to show or hide. Then, as certain checkboxes are clicked, I want an output box to join together the selected snippets of text into an email message. But I want all of this to happen in the user's browser, i.e. I don't want any posting back to the server. This is because I want this to work on a mobile phone, and not constantly wait for the slow mobile network. At the moment I have it working but it requires a Submit button which causes posting back to the server. How can I do this client side only?

RE: How to show or hide controls using checkbox click, client-side?

You will have to use javascript. I would suggest using JQuery which uses javascript, but it just makes doing javascript coding simpler.

Here is a link to the documentation and an example with just what you need.
http://jquery.com/

RE: How to show or hide controls using checkbox click, client-side?

I agree about the use of Jquery. Sometimes finding the correct ID can be difficult with serverside controls and javascript.
one very usefull snippit for doing so is to refer to the server controls clientId property.
e.g.
<script type='text/javascript'>
$('#<%=txtContent.ClientID%>').hide()
</script>
Would hide the control with an id of txtContent even after asp has renamed it.
The other trick i will use sometime is to asign a css class to a control and use the class to target the control instead as asp.net never messes with classes.

for what it is worth.

RE: How to show or hide controls using checkbox click, client-side?

You can also set the clientIDMode = "Static" on the control and just use the control name. This way if you have a control within a control, it won't matter

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close