How to insert data into sql server databse using jquery (post method) in
Here I have explain how to Insert Data Into SQL Server database Using jQuery (post method) in ASP.Net with out creating web service.

Last 5 inserted record.
IDContact NameContact No


<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ContactInfo.aspx.cs" Inherits="ASPJquerySaveData.ContactInfo1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="Scripts/jquery-1.7.1.js"></script>
        $(document).ready(function () {
            $('#btnSave').click(function () {
                var contactName = $('#<%=txtContactName.ClientID%>').val();
                var contactNo = $('#<%=txtContactNo.ClientID%>').val();

                if (contactName.trim() == "" || contactNo.trim() == "") {
                    alert("All the fields are required!");
                    return false;


                // here call server side function for save data using jquery ajax
                    url: "ContactInfo.aspx/SaveData",
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify({
                        "contactName": contactName,
                        "contactNo" : contactNo
                    success: function (data) {
                        if (data.d == "success") {
                            alert("Data saved successfully");
                            // clear text here after save complete
                    error: function (xhr, ajaxOptions, thrownError) {
                }).done(function () {
                    // here hide loading panel as function complete
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h3>Insert Data Into SQL Server Using jQuery (post method) in ASP.Net</h3>
                <td>Contact Name : </td>
                <td><asp:TextBox ID="txtContactName" runat="server" Width="200px" /></td>
                <td>Contact No: </td>
                <td><asp:TextBox ID="txtContactNo" runat="server" Width="200px" /></td>
                    <input type="button" value="Submit" id="btnSave" />
                    <div id="loadingPanel" style="color:green; font-weight:bold;display:none;">Please wait! Data Saving...</div>

Posted By : Sourav Mondal