This is a migrated thread and some comments may be shown as answers.

[Solved] AutoComplete serverside bind using AJAX=404

0 Answers 59 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ofer
Top achievements
Rank 1
Ofer asked on 05 Apr 2011, 01:44 PM
Hi,
I have a problem with implementing autocomplete via serverside population using ajax.
i always get: Error! The requested URL returned 404 - error
Standard population works ok.
My controller looks like this:

 

 

public class HomeController : Controller

 

{

 

 

public ActionResult Index()

 

 

{

 

ViewBag.Message =

 

"Welcome to ASP.NET MVC!";

 

 

 

 

CommonRequests cr = new CommonRequests();

 

 

 

 

Device [] devices = cr.GetDeviceList("");

 

 

 

 

ViewBag.Devices = devices;

 

 

 

return View();

 

 

}

 

[

 

HttpPost]

 

 

 

 

public ActionResult _FilteringAjax(string text, int? filterMode)

 

 

{

 

 

 

CommonRequests cr = new CommonRequests();

 

 

 

 

Device[] devices = cr.GetDeviceList(text);

 

 

 

 

 

 

return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new

 

 

 

SelectList(devices.ToList(), "ID", "SoftwareVersion")

 

 

};

 

}

 

[

 

HttpPost]

 

 

 

 

public ActionResult _AutoCompleteFilteringAjax(string text, int? filterMode)

 

 

{

 

 

 

CommonRequests cr = new CommonRequests();

 

 

 

 

Device[] devices = cr.GetDeviceList(text);

 

 

 

 

return new JsonResult { Data = devices.Select(d => d.ID) };

 

 

}

 

 

 

public ActionResult About()

 

 

{

 

 

 

return View();

 

 

}

 

}

The view looks like this:

 

 

<h3>AJAXAutoComplete</h3>

 

 

@(Html.Telerik().AutoComplete()

 

.Name(

 

"AJAXAutoComplete")

 

 

.AutoFill(

 

false)

 

 

.DataBinding(binding => binding.Ajax()

 

.Select(

 

"_AutoCompleteFilteringAjax", "HomeController")

 

 

.Delay(400)

 

.Cache(

 

true)

 

 

)

 

.Filterable(filtering =>

 

{

 

filtering.FilterMode(

 

AutoCompleteFilterMode.StartsWith);

 

 

filtering.MinimumChars(3);

 

})

 

.Multiple(multi =>

 

{

 

multi.Separator(

 

", ")

 

 

.Enabled(

 

true);

 

 

})

 

.HighlightFirstMatch(

 

true)

 

 

 

 

)

 

 

 

 

<script type="text/javascript">

 

 

 

function onComboBoxDataBinding(e)

 

 

{

 

e.data = $.extend({}, e.data, { filterMode:

 

$(

 

'#ComboBoxAttributes_FilterMode').data('tDropDownList').value()

 

 

});

 

}

 

 

 

function onAutoCompleteDataBinding(e) {

 

 

 

 

e.data = $.extend({}, e.data, { filterMode:

 

"1"});

 

// $('#AutoCompleteAttributes_FilterMode').data('tDropDownList').value()

// });

}

 

 

</script>

 


Please help...
THNX
Alon
Tags
ComboBox
Asked by
Ofer
Top achievements
Rank 1
Share this question
or