locked
Help solution RRS feed

All replies

  • User177399542 posted

    Please check this: Jquery JSON Add,Edit,Update,Delete in Asp .Net

    Friday, November 25, 2016 5:57 AM
  • User950190560 posted
    Thanks but i need script from my link .
    Friday, November 25, 2016 6:53 AM
  • User-707554951 posted

    Hi mluci,

    I read the article you provided carefully.

    It mainly teacher us how to communicate with our database using jQuery AJAX and ASP.NET.

    The main technical is using ajax call web method.

    Following is an working example how to call webmethod using jwuery ajax.

    You could refer to it:

     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script type = "text/javascript">
    function ShowCurrentTime() {
        $.ajax({
            type: "POST",
    url: "set date in html textbox from ajax.aspx/GetCurrentTime",
            data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function(response) {
                alert(response.d);
            }
        });
    }
    function OnSuccess(response) {
        alert(response.d);
    }
    </script>

      <div>
    Your Name :
    <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
    <input id="btnGetTime" type="button" value="Show Current Time"
        onclick = "ShowCurrentTime()" /> 
    </div>

    CodeBehind:

    [System.Web.Services.WebMethod]
            public static string GetCurrentTime(string name)
            {
                return "Hello " + name + Environment.NewLine + "The Current Time is: "
                + DateTime.Now.ToString();
            }

    For information about Retrieve data from Database and display on page using jQuery AJAX in ASP.Net.

    You could refer to the following link:

    http://www.aspsnippets.com/Articles/Retrieve-data-from-Database-and-display-on-page-using-jQuery-AJAX-in-ASPNet.aspx

    Best regards

    Cathy

    Friday, November 25, 2016 10:03 AM