hide div after just showing-VBForums
Results 1 to 2 of 2

Thread: hide div after just showing

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    513

    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>
    There is no achievement without goals

  2. #2
    Junior Member Bharathi P's Avatar
    Join Date
    Dec 2013
    Location
    Chennai, India
    Posts
    17

    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 View Post
    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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.