Click here to Skip to main content
12,554,869 members (59,343 online)
Click here to Skip to main content
Add your own
alternative version


7 bookmarked

Show/hide elements dynamically in web page

, 6 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Show/hide elements dynamically in web page


How to Show/hide elements dynamically in web page via Server-side/client-side. Let's take a DIV for example:


<div id="Div1"  runat="server">
//To show
Div1.Visible = true;
//To hide
Div1.Visible = false;
Client-side - JavaScript

Using Visibility property
div = document.getElementById('<%=Div1.ClientID%>')
//To show"visible";
//To hide"hidden";
Using display property:
div = document.getElementById('<%=Div1.ClientID%>')
//To show"block";
//To hide"none";
Client-side - jQuery
//To show
//To hide

Further Reading


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
Retired from Q/A section & Technical forums since 2014

More coming soon....

You may also be interested in...


Comments and Discussions

GeneralHow about ClientID for server div? Maybe you miss something?... Pin
Anton Levshunov6-Feb-12 10:26
memberAnton Levshunov6-Feb-12 10:26 
GeneralRe: Yep, I forgot to include the ClientIDs. Now I have updated t... Pin
thatraja6-Feb-12 19:47
mvpthatraja6-Feb-12 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 7 Feb 2012
Article Copyright 2012 by thatraja
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid