Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC3 ASP.NET4.0
Hi,
 
I have been using Telerik controls, I was using server binding, but I have to use Ajax binding, that is not working properly, I am getting Error "Error! The requested URL did not return JSON asp.net mvc"
Following is the Code in My Controller
[GridAction]
        [Authorize(Roles = "Admin")]
        public ActionResult Edit(int id)
        {
            Contact model = _cService.getContact(id, applicationID);
            GetContactType();
            if (model != null)
                return View(new GridModel());
            else
            return View();
        }
 

        //
        // POST: /Contact/Edit/5
        [GridAction]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(int id, Contact model)
        {
            try
            {                         
                _cService.SaveContact(model, applicationID); 
                return RedirectToAction("Index");
            }
            catch
            {
                return Json(new GridModel());
            }
        }
        public virtual JsonResult GetParents()
        {
            return GetContactsByType(2);
        }
        public virtual JsonResult GetContactsByType(int? id)
        {
            List<contact> list;
            if (id.HasValue)
              list=  _cService.GetContactCollections(applicationID).Where(x => x.ContactTypeId == id.Value).ToList();
            else
                list = _cService.GetContactCollections(applicationID).ToList();
            return new JsonResult
            {
                Data = list,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, // you may or may not need this line, depending upon your server config
            };
        }</contact>
 
and following Code in my view
  @(Html.Telerik().Grid(Model)
        .Name("Contact")
              //  .ToolBar(commands => commands.Insert())
       .DataKeys(keys => keys.Add(c => c.Id))
        
        .DataBinding(dataBinding => 
        {
             
            dataBinding.Ajax()
            
            .Update("Edit", "Contact", new { mode = GridEditMode.InForm, type = GridButtonType.Text })
            .Delete("Delete", "Contact", new { mode = GridEditMode.InLine, type = GridButtonType.Text });
        })
                   
        .Columns(columns =>
        {
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Text);
                commands.Delete().ButtonType(GridButtonType.Text);
            }).Width(180).Title("Manage");
          columns.Template(o=> @Html.ActionLink(o.LastName, "Details",new {id=o.Id})).Title("LastName").Width(130);
          columns.Bound(o => o.FirstName).Width(160);
          columns.Bound(o => o.Address).Width(110);
          columns.Bound(o => o.CellPhone).Width(110);
          columns.Bound(o => o.HomePhone).Width(110);
          
        })
What I can do this Error, this error arise using Alert box, I have tried Modifying telerik.grid.min.js I have removed the line that,then it does not shows me error but also does not work.
Can somebody please give me Some suggestions.
Thank You
Posted 3-Jul-12 9:39am
Comments
Christian Graus at 18-Jul-12 19:06pm
   
Given that you've bought the Telerik library, I'd think their support would be the best place to look for help with their controls
Christian Graus at 18-Jul-12 19:07pm
   
Looks like you've asked this on every site on the web, except the Telerik site...

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 485
1 OriginalGriff 285
2 Peter Leow 260
3 Maciej Los 195
4 John C Rayan 162
0 Sergey Alexandrovich Kryukov 7,203
1 OriginalGriff 5,587
2 Peter Leow 4,097
3 Mika Wendelius 2,850
4 CHill60 2,818


Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2015
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