Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am trying to use simple jquery inside content place holder in my asp.net web application. While running the aaplication, it is working when the page gets loaded. After the page load, jquery stops working unfortunately. I hav placed my code below. Can anybody help?

ASP.NET
<%@ Page Language="C#" CodeBehind="NewPage.aspx.cs" MasterPageFile="~/Site.Master" Inherits="WebApplication5.NewPage" %>

<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">


<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <header>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $(".btnnn").click(function () {
                    $("p").toggle("slow");

                });
            });
        </script>

    </header>

    <div>
        <p id="para">Click the button to hide this!!!</p>

    </div>

    <div>
        <asp:Button ID="Button1" CssClass="btnnn" runat="server" Text="Hide It" />
    </div>
Posted
Updated 2-Mar-15 19:40pm
v4

1 solution

the Code you have written is good only, try attribute OnClientClick = "return false"

ASP.NET
<asp:button id="Button1" cssclass="btnnn" runat="server" text="Hide It" onclientclick="return false" />
 
Share this answer
 
v2
Comments
arunkx 3-Mar-15 2:10am    
Superb!!! It worked. Thanks Mr.Raja :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900