Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Typeahead和服务器端onTextChanged事件未正确同步_Javascript_C#_Jquery_Asp.net_Typeahead - Fatal编程技术网

Javascript Typeahead和服务器端onTextChanged事件未正确同步

Javascript Typeahead和服务器端onTextChanged事件未正确同步,javascript,c#,jquery,asp.net,typeahead,Javascript,C#,Jquery,Asp.net,Typeahead,我有一个文本框,它将Typeahead(自动完成)和服务器端onTextChanged事件绑定到同一个文本框。这两个事件未正确同步。当我点击一些名为“a”的文本时,会显示类似“apple”的建议,我选择“apple”表示仅在服务器(codebehind)上捕获的文本“a”的上文本更改方法。请给出一些解决方法 <asp:TextBox ID="txtEntityId1" name="txtEntityId1" placeholder="Search" style="width: 273px

我有一个文本框,它将Typeahead(自动完成)和服务器端onTextChanged事件绑定到同一个文本框。这两个事件未正确同步。当我点击一些名为“a”的文本时,会显示类似“apple”的建议,我选择“apple”表示仅在服务器(codebehind)上捕获的文本“a”的上文本更改方法。请给出一些解决方法

 <asp:TextBox ID="txtEntityId1" name="txtEntityId1" placeholder="Search" style="width: 273px"  class="nav-search-input" runat="server" onTextChanged="text_changed" AutoPostBack="true" AutoComplete="Off"></asp:TextBox>


var EntityText = document.getElementById('<%=txtEntityId1.ClientID %>');
            try {
                $(EntityText).typeahead({
                    source: entityName,
                    updater: function (item) {
                        $(EntityText).focus();
                        return item;
                    }
                });
            } catch (e) { alert(e.Message + " , " + e.InnerException); }

protected void text_changed(object sender, EventArgs e)
        { 
            string EntityName = txtEntityId1.Text;
            if (EntityName != "")
            {
       }
                else
                {   //Added Check for Invalid Entity Error Message.
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "bootbox.alert('<h4 class=\"blue\">Select Valid Entity</h4>', function() {});", true);
            }
}

var EntityText=document.getElementById(“”);
试一试{
$(EntityText)。提前键入({
来源:entityName,
更新程序:函数(项){
$(EntityText.focus();
退货项目;
}
});
}catch(e){alert(e.Message+,“+e.InnerException);}
受保护的无效文本\u已更改(对象发送方,事件参数e)
{ 
字符串EntityName=txtEntityId1.Text;
如果(EntityName!=“”)
{
}
其他的
{//添加了对无效实体错误消息的检查。
Page.ClientScript.RegisterStartupScript(this.GetType(),“Script”,“bootbox.alert('Select Valid Entity',function(){});”,true);
}
}

TextChanged在模糊事件发生时激发,并将value属性中的内容发回。使用调试器找出输入值是什么,并检查所有内容是否已连接。插件可能不会更新文本框的value属性;这些小部件有时无法按预期的方式运行,因此您必须确保输入的值正在更新

您是否可以在保存单击期间或在客户端上检测该值是否有效