如何在另一个按钮中调用按钮单击事件单击Jquery

时间:2016-05-09 13:15:16

标签: jquery asp.net json

enter image description here 以下代码用于从数据库中获取特定用户数据 并显示在Readable Textbox's 我有另一套Textbox's用于insert data into database,在插入数据后我想获取该数据并显示在Readable Textboxtxtuser Textbox

// this jquery code execute when we click on `Get Button`

        $('#btnGet').click(function(){
          var txtuser = $('#txtuser').val();
          $.ajax({
          contentType: 'application/json; charset=utf-8',
                        url: 'WebForm1.aspx/GetUser',
                        data: JSON.stringify({ username: txtuser}),
                        dataType: 'json',
                        method: 'post',
                        success: function (data) {                                                            $('#txtfirstname').val(data.d.Firstname);
                            $('#txtlastname').val(data.d.Lastname);
                            $('#txtemail').val(data.d.Email);
                        },
                        error: function (result) {
                            alert('Error');
                        }
        });
    return false;
        });


 // this jquery code execute when we click on `Submit Button`

            $('#btnSubmit').click(function(){
              var txtuser = $('#txtuser').val();
var txtfirstname =  $('#txtfirstname').val();
var txtlastname =  $('#txtlastname').val();
var txtemail =  $('#txtemail').val();
              $.ajax({
              contentType: 'application/json; charset=utf-8',
                            url: 'WebForm1.aspx/InsertUser',
                            data: JSON.stringify({ username: txtuser, firstname:txtfirstname, lastname : txtlastname, email:txtemail}),
                            dataType: 'json',
                            method: 'post',
                            success: function (data) {                                                            $('#txtfirstname').val(data.d.Firstname);
                                $('#txtlastname').val(data.d.Lastname);
                                $('#txtemail').val(data.d.Email);
                            },
                            error: function (result) {
                                alert('Error');
                            }
            });
        return false;
            });

如何实现这一任何帮助

0 个答案:

没有答案