hide div after just showing
I have following jquery code ..and when I click on button it shows main div and then hide right after it ..any help
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddComment.aspx.cs" Inherits="Real_etsate.AddComment" %>
<!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="js/jquery.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
function CallService1() {
$.ajax({
type: "POST",
url: "MyService.asmx/Addtodb",
data: "{ 'value1': " + "'" + $("#txt_comments").val() + "'" + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
}
function OnSuccess(data, status) {
if(data.d == "Valid User")
{
// $("#lblResult").html(data.d);
// $("#main").fadeIn("slow");
}
// if(data.d == "In_Valid User")
// $("#main").slideUp("slow");
// alert(data.d);
}
function OnError(request, status, error) {
//// $("#lblResult").html(request.statusText);
////
//// $("#main").slideUp("slow");
}
//
//
$(document).ready(function() {
$("#lnk_btn").click(function() {
$("#main").show(); //You can replace this with .toggle() if you want to toggle the visibility
////
// $("#main").slideDown("slow");
});
});
</script>
<link rel="stylesheet" type="text/css" href="CSS/style.css"/>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="lnk_btn" runat="server" Text="Insert Comments" />
<div id="main" runat="server" style="display: none;">
<div>
<asp:TextBox ID="txt_comments" runat="server"></asp:TextBox>
<asp:Button ID="Button1" OnClientClick="CallService1(); return false;" runat="server" Text="Button" />
</div>
</div>
</form>
</body>
</html>
Re: hide div after just showing
Hi,
You can use HTML Input button instead of <asp:Button ID="lnk_btn" runat="server" Text="Insert Comments" />.
Dont use runat="server" tag in html button.
Regards,
Bharathi P
Quote:
Originally Posted by
ERUM
I have following jquery code ..and when I click on button it shows main div and then hide right after it ..any help
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddComment.aspx.cs" Inherits="Real_etsate.AddComment" %>
<!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="js/jquery.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
function CallService1() {
$.ajax({
type: "POST",
url: "MyService.asmx/Addtodb",
data: "{ 'value1': " + "'" + $("#txt_comments").val() + "'" + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
}
function OnSuccess(data, status) {
if(data.d == "Valid User")
{
// $("#lblResult").html(data.d);
// $("#main").fadeIn("slow");
}
// if(data.d == "In_Valid User")
// $("#main").slideUp("slow");
// alert(data.d);
}
function OnError(request, status, error) {
//// $("#lblResult").html(request.statusText);
////
//// $("#main").slideUp("slow");
}
//
//
$(document).ready(function() {
$("#lnk_btn").click(function() {
$("#main").show(); //You can replace this with .toggle() if you want to toggle the visibility
////
// $("#main").slideDown("slow");
});
});
</script>
<link rel="stylesheet" type="text/css" href="CSS/style.css"/>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="lnk_btn" runat="server" Text="Insert Comments" />
<div id="main" runat="server" style="display: none;">
<div>
<asp:TextBox ID="txt_comments" runat="server"></asp:TextBox>
<asp:Button ID="Button1" OnClientClick="CallService1(); return false;" runat="server" Text="Button" />
</div>
</div>
</form>
</body>
</html>