Here I will explain how to show / hide div using jQuery or jQuery Show & hide div content elements using JQuery in asp.net.
In previous post I explained many articles relating to JQuery. Now in this article I will explain how to show or hide div or table elements on website using JQuery in asp.net. In many websites we will be able to see functionality like whenever we click on some link automatically that div or table will hide and again if we click on same link that will be visible for us we can implement that functionality by using JQuery
First open Visual Studio and create new website after that write following code in your aspx page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JQuery Show / Hide Div panels in asp.net</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#lnkbtn").click(function() {
if ($('#divreg').is(":hidden")) {
$('#divreg').show(500);
document.getElementById('lnkbtn').innerHTML = "Hide";
} else {
$("#divreg").hide(500);
document.getElementById('lnkbtn').innerHTML="Show";
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td><asp:LinkButton ID="lnkbtn" runat="server"><b>Hide</b></asp:LinkButton> </td>
</tr>
<tr>
<td>
<div id="divreg">
<table style="border:1px solid #000">
<tr>
<td colspan="2"><b>Registration Details</b></td>
</tr>
<tr>
<td>UserName:</td>
<td><asp:TextBox ID="txtUser" runat="server"/></td>
</tr>
<tr>
<td>Password:</td>
<td><asp:TextBox ID="TextBox1" runat="server"/></td>
</tr>
<tr>
<td><asp:RadioButtonList ID="rdbtnGender" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|

Subscribe by RSS
Subscribe by Email
3 comments :
The work you are doing here is amazing. Useful articles. Thank you
hi chanceless really very nice ur way of presenting all articles .......
hey hi...you going good....
but the following post is not working properly
"JQuery hide/show div content elements in asp.net"(http://www.aspdotnet-suresh.com/2012/04/jquery-hideshow-div-content-lements-in.html#gsc.tab=0)
plz check and reply