Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.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
C# 无法从html输入检索值(自动完成jquery ui)_C#_Html_Visual Studio_Extract - Fatal编程技术网

C# 无法从html输入检索值(自动完成jquery ui)

C# 无法从html输入检索值(自动完成jquery ui),c#,html,visual-studio,extract,C#,Html,Visual Studio,Extract,我有一个html自动完成文本框,我的问题是当我尝试输入一个地址时,例如“纽约”,然后单击提交按钮。它不会检索输入值。(不返回任何值) Test.aspx <!--Address--> <div class="form-group"> <label class="col-sm-3 control-label no-padding-right">Address</label> <div class="c

我有一个html自动完成文本框,我的问题是当我尝试输入一个地址时,例如“纽约”,然后单击提交按钮。它不会检索输入值。(不返回任何值)

Test.aspx

<!--Address-->
    <div class="form-group">
         <label class="col-sm-3 control-label no-padding-right">Address</label>
         <div class="col-sm-7">

            <input id="tb_address" type="text" class="form-control" placeholder="Type 'a' or 'h'" />

    </div>
</div>

地址
Test.aspx页面中的我的javascript代码

<script type="text/javascript">
        jQuery(function ($) {


            //custom autocomplete (category selection)
            $.widget("custom.catcomplete", $.ui.autocomplete, {
                _renderMenu: function (ul, items) {
                    var that = this,
                    currentCategory = "";
                    $.each(items, function (index, item) {
                        if (item.category != currentCategory) {
                            ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
                            currentCategory = item.category;
                        }
                        that._renderItemData(ul, item);
                    });
                }
            });

            var data = [
               { label: "New York", category: "North" },
           { label: "Rochester", category: "North" },
           { label: "California", category: "North" },

            ];
            $("#tb_address").catcomplete({
                delay: 0,
                source: data
            });




        });
    </script>

protected void bn_Submit_Click(object sender, EventArgs e)
{
  string address = Request.Form["tb_address"];

   lb_msg.Text = address;
}

jQuery(函数($){
//自定义自动完成(类别选择)
$.widget(“custom.catcomplete”,$.ui.autocomplete{
_renderMenu:功能(ul,项目){
var=这个,
currentCategory=“”;
$。每个(项目、功能(索引、项目){
如果(item.category!=当前类别){
ul.追加(“
  • ”+item.category+“
  • ”); currentCategory=item.category; } 即._renderItemData(ul,项目); }); } }); 风险值数据=[ {标签:“纽约”,类别:“北方”}, {标签:“罗切斯特”,类别:“北方”}, {标签:“加利福尼亚”,类别:“北方”}, ]; $(“tb地址”).catcomplete({ 延迟:0, 资料来源:数据 }); }); 受保护的无效bn\u提交\u单击(对象发送者,事件参数e) { 字符串地址=请求。表单[“tb_地址”]; lb_msg.Text=地址; }
    我发现您的输入没有名称,请按如下方式调整输入标记,然后重试:

    <input id="tb_address" name="tb_address" type="text" class="form-control" placeholder="Type 'a' or 'h'" />
    
    
    
    您使用的是ASP.NET输入控件还是常规HTML输入?HTML源“tb_地址”中是否包含您的姓名?你需要提供更多的代码和信息,我们才能帮助你。你是对的,现在我设法在标签上显示文本。非常感谢你,伙计!!!