This question is locked. New answers and comments are not allowed.
Hi, I have been using Telerik for more than a year and it is the first time that I am stuck in a problem that I can't solve. After one day of tests, I have to call for help :)
I am trying to use the combobox from telerik (MVC3 - Razor), example here : http://demos.telerik.com/aspnet-mvc/razor/combobox/ajaxloading
But I can't make it work. Instead of calling the correct URL in the Ajax call, it calls localhost:portnumber/Home/null with the correct data post (text : somestring) so I have a dialog message : Error! The requested URL returned 404 - Not Found
I am using version 2011.3.1115
With previous version (2011.2.914), I have the same error.
I am surely doing something wrong but I can't see what...
Here is my code
View (Test.cshtml)
My controller (HomeController)
Global.asax
Thanks in advance for your help.
Francis.
I am trying to use the combobox from telerik (MVC3 - Razor), example here : http://demos.telerik.com/aspnet-mvc/razor/combobox/ajaxloading
But I can't make it work. Instead of calling the correct URL in the Ajax call, it calls localhost:portnumber/Home/null with the correct data post (text : somestring) so I have a dialog message : Error! The requested URL returned 404 - Not Found
I am using version 2011.3.1115
With previous version (2011.2.914), I have the same error.
I am surely doing something wrong but I can't see what...
Here is my code
View (Test.cshtml)
@{ ViewBag.Title = "Test"; Layout = string.Empty;}<h2>Test</h2>Search : @(Html.Telerik().ComboBox() .Name("AjaxComboBox") .AutoFill(true) .DataBinding(binding => binding.Ajax().Select("_Search", "Home")) .Filterable(filtering => { filtering.MinimumChars(3); }) .HighlightFirstMatch(true) )@(Html.Telerik().ScriptRegistrar().jQuery(true).Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)))My controller (HomeController)
public class HomeController : Code.MyBaseController { public ActionResult Test() { return View(); } [HttpPost] public ActionResult _Search(string text) { if (text.Length < 3) { return new JsonResult { Data = null }; } Search s = new Search(); var result = s.SearchText(text, 10); return new JsonResult { Data = result }; } }Base controller :using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using System.IO;namespace SiteSC2.Code{ public abstract class MyBaseController : Controller { private string title; protected string Title { get { return title; } set { title = value; ViewBag.Title = value; } } protected string RenderPartialViewToString() { return RenderPartialViewToString(null, null); } protected string RenderPartialViewToString(string viewName) { return RenderPartialViewToString(viewName, null); } protected string RenderPartialViewToString(object model) { return RenderPartialViewToString(null, model); } protected string RenderPartialViewToString(string viewName, object model) { if (string.IsNullOrEmpty(viewName) == true) { viewName = ControllerContext.RouteData.GetRequiredString("action"); } ViewData.Model = model; using (StringWriter sw = new StringWriter()) { ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName); ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw); viewResult.View.Render(viewContext, sw); return sw.GetStringBuilder().ToString(); } } public MyBaseController() { } }}Global.asax
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}/{language}", // URL with parameters new { controller = "Home", action = "Index", language=UrlParameter.Optional, id = UrlParameter.Optional } // Parameter defaults);Thanks in advance for your help.
Francis.