Click here to Skip to main content
Click here to Skip to main content

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
Programmer | Dude | ||||||
About him & his blog? check out here. Currently he's updating the site, he'll return soon there with more things*.
In Codeproject, he posted a blogpost & more than couple of Tip/Tricks, hope he'll write more soon.
Favorite techs are MVC, WCF, Mobile, HTML5, CSS3, jQuery, etc.,
His hobbies are watching movies, CP, being alone, etc., But now he's working on something*.
* - SCAMP???
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

Questionusing server side method, the hidden div won't show up Pinmembert4nu17-Dec-14 14:39 
AnswerRe: using server side method, the hidden div won't show up Pinprotectorthatraja18-Dec-14 15:37 
QuestionHide elements PinmemberMember 104863646-Sep-14 19:58 
AnswerRe: Hide elements Pinprotectorthatraja11-Sep-14 3:17 
QuestionClient side without reload the page? PinmemberIgor Maozao9-Feb-13 4:34 
GeneralHow about ClientID for server div? Maybe you miss something?... PinmemberAnton Levshunov6-Feb-12 11:26 
GeneralRe: Yep, I forgot to include the ClientIDs. Now I have updated t... Pinmvpthatraja6-Feb-12 20:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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.150129.1 | Last Updated 7 Feb 2012
Article Copyright 2012 by thatraja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid