$(document).ready() is a Jquery Event.It fires when DOM is loaded and ready to manipulated by script.This is the earliest point in the page load process where the script can access pages HTML dom. This event fires before the images,css etc are fully loaded.
In the below code we use Jquery inside the Content page so we write '#<%= Button1.ClientID %>' on the place of '# Button1' because all the elements access on content page by ClientID.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="GridviewData.aspx.cs" Inherits="GridviewData" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
);
</script>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</asp:Content>
NOw replace the
$(document).ready(function(){
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
);
Code with following code this will not work properly because of we remove the $(documnet).ready() function.when you click on button you don't get alert message because
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
In the below code we use Jquery inside the Content page so we write '#<%= Button1.ClientID %>' on the place of '# Button1' because all the elements access on content page by ClientID.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="GridviewData.aspx.cs" Inherits="GridviewData" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
);
</script>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</asp:Content>
NOw replace the
$(document).ready(function(){
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
);
Code with following code this will not work properly because of we remove the $(documnet).ready() function.when you click on button you don't get alert message because
$('#<%= Button1.ClientID %>').click(function () {
alert('Hello Sudhir Singh');
}
);
}
No comments:
Post a Comment