Skip to main content
 首页 » 编程设计

c#之当用户输入时,字符串的其余部分消失

2024年02月23日23xing901022

在搜索文本框中,当用户输入 & 之后的文本不会传递给该函数。 因此,如果输入并提交了 industry & test,则只会将 industry 传递给该函数。我如何接受放大器的声音?

文本框:

 Search <input type="text" id="searchtxt" /><img class ="SearchNow"src="/Content/img/search1.png"/> 

Jquery调用函数:

 $(".SearchNow").click(function () { 
        var selected = $('#searchtxt').val(); 
        if (selected != null) { 
            if (selected != "") { 
                window.location = '@Url.Action("search", "Products")?partnumber=' + selected; 
            } 
        } 
    }); 

没有全部输入文本的函数:

 public ActionResult search(string partnumber) 
    { 
 
 
    } 

请您参考如下方法:

包裹它:

encodeURIComponent(selected)