I am quit new in jquery. I have implemented the jquery autocomplete textbox, where I load data from SQL server. Upon selecting an item from the dropdown, I fill some controls on the form. I also want to change the text property of a button. Below is my jquery code:

$(function () {
        $("#<%=txtSearch.ClientID%>").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/customers/customers.asmx/fncFetchCustomerList",
                    data: "{ 'strFullname': '" + request.term + "' }",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataFilter: function (data) { return data; },
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                value: item.Fullname,
                                Firstname: item.FirstName,
                                Email: item.Email
                            }
                        }))
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(textStatus);
                    }
                });
            },
            select: function (event, ui) {
                $('#<%=txtFName.ClientID%>').val(ui.item.Firstname);
                $('#<%=txtEmail.ClientID%>').val(ui.item.Email);
                $('#<%=btnSubmit.ClientID%>').val("Update");
            },
            minLength: 2
        });
    });

My problem is, upon changing the text property of the button to "Update", when i run a server side code and check for the text of the button, it doesn't read "Update".
Any help on this will be appreciated.
Thank you.

The problem is going to most likely be caused because of viewstate. You are updating the text of the button on the client side which does not update the page's viewstate. When the postback occurs and the page fetches the viewstate data it will not see the updated text value for that button. One option you might try is to add a HiddenField control to the page and set it's value to "Update" in the select function of the autocomplete as well as the submit buttons text value. Then in the code behind access the hiddenfield value instead of trying to read the button's text value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.