Click here to Skip to main content
15,913,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, using javasript I managed to do an auto completion textbox. It worked in the testing app, but when I used it for the existing application, the controller method is always getting a null value. I guess the javascript function is returning a Null value. Does anyone have an idea on this? Thanks in advance!!!

code :


{
//in the  Homecontroller
           
        public JsonResult AutocompleteSuggestions(string serchtext)
        {
            var suggestions = selectEmployees.getEmployeeSuggestedNumbers(serchtext);
            return Json(suggestions, JsonRequestBehavior.AllowGet);
        }

//searchtext getting Null values from the View

<script src="<%: Url.Content("~/Scripts/jquery-1.4.4.min.js")%>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery-ui.min.js")%>" type="text/javascript"></script>


      //in the index.aspx


<h3 class="searchlabel">Search</h3>

<form1  runat="server" action = "" method="post">
 <input id="searchTerm" name="searchTerm" type="text" />&nbsp;

     <script type="text/javascript">
         $(function () {
             $("#searchTerm").autocomplete({
                 source: "/Home/AutocompleteSuggestions",
                 minLength: 1,
                 select: function (event, ol) {
                     if (ol.item) {
                         $("#searchTerm").val(ol.item.value);
                         $("form1").submit();
                     }
                 }
             });
         });
    </script>

   <%-- <% Html.RenderPartial("~/Views/Home/Search.ascx"); %>   --%>
Posted
Updated 7-Feb-13 6:39am
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900