Jquery Auto完成扩展程序在回发后无法正常工作

我使用ASP.Net中的Web服务使用jQuery自动完成。我使用自动完成来过滤员工代码。当页面加载自动完成工作正常,但在我点击搜索按钮后自动完成function无法正常工作。

我认为问题在于document.ready函数,所以当页面加载时它工作正常,但我也会在buttonclick事件后使用自动完成。 我怎样才能做到这一点 ???

inheritance我的jQuery自动完成function

    $(document).ready(function () { $("#").autocomplete({ source: function (request, response) { $.ajax({ url: '', data: "{ 'Empcode': '" + request.term + "'}", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { response($.map(data.d, function (item) { return { label: item.split('-')[1], //val: item } })) }, error: function (response) { alert(response.responseText); }, failure: function (response) { alert(response.responseText); } }); }, minLength: 1 }); });  

标记

           

ButtonSearch Codebehind

 protected void bttnSearch_Click(object sender, EventArgs e) { clsEmp.EMPLOYEEID =txtEmpCodeSrch.Text.Trim()==""? 0:Convert.ToInt32(hFieldEmpId.Value); DataTable dtEmp = clsEmp.GetDetails(); if (dtEmp.Rows.Count > 0) { hFieldEmpId.Value = ""; // txtEmpCodeSrch.Text = ""; if (ViewState["Sort"] != null) { DataView dView = new DataView(dtEmp); dView.Sort = ViewState["Sort"].ToString(); gdView.DataSource = dView; gdView.DataBind(); } else { gdView.DataSource = dtEmp; gdView.DataBind(); } } } 

如果你有一个UpdatePanel,在更新数据之后,你还需要重新初始化javascript,因为旧的不再有效,因为你的html页面的结构发生了变化,dom有了变化。

UpdatePanel提供了一些在客户端执行此操作的function,您的代码将如下所示:

  

我告诉你,我可以通过在UpdatePanel标签中添加一个触发器来解决问题,从而在我的情况下实现所需的行为。 我希望你可以为我服务,因为我帮助了我。

   //My label fire autocomplete  // Other Html Tags...