Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# MVC
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 7-Feb-13 4:15am
Hesha764
Edited 7-Feb-13 6:39am
33.9K
v5

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 258
2 ChintanShukla 195
3 Bhavik_Patel 170
4 Richard Deeming 165
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100