i have to hide a div on button click by jquery in asp.net

Posted by Shanky11 under jQuery on 5/6/2013 | Points: 10 | Views : 7080 | Status : [Member] | Replies : 4
i tried this code but not working........
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table width="100%"><tr><td>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Simple Slideshow with text overlay Example in Asp.net</title>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#hidebtn").click(function () {
$("#homedata").hide();
});

});
</script>
</head>
</html>
</asp:Content>
button---------------------------------
<asp:Button ID="hidebtn" runat="server" Text="Hide" onclick="javascript:hideFunction()"/>




Responses

Posted by: Satyapriyanayak on: 5/6/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Show_hide_div_using_button._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>

<script src="jquery/jquery-1.9.1.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$(".SHlDiv").hide();
$('.button').click(function () {
$(".SHDiv").slideToggle();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="SHDiv">
Welcome to Forums
</div>
<button class="button">Show/Hide</button>
</form>
</body>
</html>


If this post helps you mark it as answer
Thanks

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
i tried this............. tel me error in this
<%@ Page Title="DemoPage" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="jquerydemo.aspx.cs" Inherits="jquerydemo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<script src="jquery/jquery1.9.js" type="text/javascript"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table width="100%"><tr><td>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
<script type="text/javascript">
$(document).ready(function () {
$('#hidebtn').click(function () {
$('#homedata').hide();

});

});

</script>


</head>
</html>

<table width="1024px" height="600px"><tr valign="top"><td>

<div id="homedata" style="width:1024px; height:200px; background-color:Gray" >


</div>
<asp:Button ID="hidebtn" runat="server" Text="Hide" onclick="hidebtn_Click" />

</td></tr></table>

</td></tr></table>

</asp:Content>



Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
Write something inside your div so you will know whether its getting hide or no...

http://hashtagakash.wordpress.com/

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 5/6/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Check this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Day1.aspx.cs" Inherits="Day1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Jquery/Jquery.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="CSS/Day1.css" />
<script type="text/javascript">
$(document).ready(function () {
$('#btnToggle').click(function (e) {
e.preventDefault();
$('#showhide').toggle();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnToggle" runat="server" Text="Show"></asp:Button>
</div>

<div id="showhide">
This is the div to show and hide on button click
</div>
</form>
</body>

</html>

Check this

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response