Click here to Skip to main content
14,362,267 members

Show/hide elements dynamically in web page

Rate this:
4.60 (7 votes)
Please Sign up or sign in to vote.
4.60 (7 votes)
6 Feb 2012CPOL
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....

Comments and Discussions

Questionusing server side method, the hidden div won't show up Pin
t4nu17-Dec-14 14:39
membert4nu17-Dec-14 14:39 
AnswerRe: using server side method, the hidden div won't show up Pin
thatraja18-Dec-14 15:37
protectorthatraja18-Dec-14 15:37 
QuestionHide elements Pin
Member 104863646-Sep-14 19:58
memberMember 104863646-Sep-14 19:58 
AnswerRe: Hide elements Pin
thatraja11-Sep-14 3:17
protectorthatraja11-Sep-14 3:17 
QuestionClient side without reload the page? Pin
Igor Maozao9-Feb-13 4:34
memberIgor Maozao9-Feb-13 4:34 
GeneralHow about ClientID for server div? Maybe you miss something?... Pin
Anton Levshunov6-Feb-12 11:26
memberAnton Levshunov6-Feb-12 11:26 
GeneralRe: Yep, I forgot to include the ClientIDs. Now I have updated t... Pin
thatraja6-Feb-12 20:47
protectorthatraja6-Feb-12 20: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.

Posted 5 Feb 2012


7 bookmarked