Description
How to Show/hide elements dynamically in web page via Server-side/client-side. Let's take a
DIV
for example:
Code
<div id="Div1" runat="server">
Server-side(ASP.NET/C#)
Div1.Visible = true;
Div1.Visible = false;
Client-side - JavaScript
Using
Visibility
property
div = document.getElementById('<%=Div1.ClientID%>')
div.style.visibility="visible";
div.style.visibility="hidden";
Using
display
property:
div = document.getElementById('<%=Div1.ClientID%>')
div.style.display="block";
div.style.display="none";
Client-side - jQuery
$('#<%=Div1.ClientID%>').show();
$('#<%=Div1.ClientID%>').hide();
Further Reading