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

Internal server error 500 on Ajax actions

5 Answers 506 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Szymon
Top achievements
Rank 1
Szymon asked on 20 May 2011, 01:35 PM
Hi all,

I found many posts here and there about this error, but none seemed to fit my scenario.
My grid is fairly simple, almost like the one form the sample app. I renamed my columns and added a column template to display "Edit" and "Details" links, and having to add a "Render()" action.

Now anytime a want to use AJAX (filtering, paging, refreshing), I get an "Error! The requested URL returned 500 - error"
Further investigation with FireBug tells me that the server returnd this:
The partial view '_Index' was not found. The following locations were searched:
~/Views/InternalProposal/_Index.aspx
~/Views/InternalProposal/_Index.ascx
~/Views/Shared/_Index.aspx
~/Views/Shared/_Index.ascx
and so on...



I am totaly lost. I suspect the added "render()" action to mess things up..


This is my view:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Internal Proposal</h2>
    <% if (Model.Count() == 0)
           {%>
    DB empty
    <%
            }
           else
           {%>
    <% Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.caseID).Title("#Case").Width(80);
            columns.Bound(o => o.status).Title("Status");
            columns.Bound(o => o.id_agree).Title("#Agree");
            columns.Bound(o => o.date_reg).Format("{0:dd/MM/yyyy}").Width(80).Title("Registration Date");
            columns.Bound(o => o.car_vin_no).Width(160).Title("VIN");
            columns.Bound(o => o.date_reply).Format("{0:dd/MM/yyyy}").Width(80).Title("Reply date");
            columns.Bound(o => o.user_reply).Title("User Reply");
            columns.Template(o =>
                {%>
    <%=Html.ActionLink("Edit", "Edit", new {id = o.id_main})%>
    |
    <%=Html.ActionLink("Details", "Details", new {id = o.id_main})%>
    <%})
                .ClientTemplate("<a href='" + Url.Action("Edit", "InternalProposal") + "/<# id_main #>Edit</a>" +
                                " | <a href='" + Url.Action("Details", "InternalProposal") + "/<# id_main #>Details</a>").Title(
                                    "").Width(100);
 
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Server().Select("Index", "InternalProposal", new { ajax =
                ViewData["ajax"] });
            dataBinding.Ajax().Select("_Index", "InternalProposal").Enabled((bool)ViewData["ajax"]);
        })
        .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
        .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
        .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
        .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
        .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
        .Footer((bool)ViewData["showFooter"])
        .Render();%>
         
    <%}%>
    <br />
    <p>
        <%: Html.ActionLink("Add Proposal", "Create") %>
    </p>
</asp:Content>

This is my controller:
public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
    bool? grouping, bool? showFooter)
{
    ViewData["ajax"] = ajax ?? true;
    ViewData["scrolling"] = scrolling ?? true;
    ViewData["paging"] = paging ?? true;
    ViewData["filtering"] = filtering ?? true;
    ViewData["grouping"] = grouping ?? true;
    ViewData["sorting"] = sorting ?? true;
    ViewData["showFooter"] = showFooter ?? true;
 
    var viewModel = new InternalProposalHeader[] { };
    viewModel = GetIntenalProposalHeaders(providerID); //ProviderID - from session info
    return View(viewModel);
}
 
 
//Action for Telerik Grid AJAX
[GridAction]
public ActionResult _Index()
{
    var viewModel = new InternalProposalHeader[] { };
    viewModel = GetIntenalProposalHeaders(providerID); //ProviderID - from session info
    return PartialView(viewModel);
}

5 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 20 May 2011, 01:37 PM
Hi Szymon,

 You must use the GridModel class as specified in the documentation.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Szymon
Top achievements
Rank 1
answered on 20 May 2011, 03:23 PM
Hi Atanas!

Thank you! Indeed I forgot the GridModel(Model) thingee. The internal server error disapeared, but I still can't get my AJAX functions working.
Now I get this error:

o.display is not a function

:(

Best regards.
Szymon
0
Atanas Korchev
Telerik team
answered on 23 May 2011, 07:45 AM
Hello Szymon,

 Is there a chance to send us a sample project? This is not a known problem and we are not sure what may be causing it.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Szymon
Top achievements
Rank 1
answered on 24 May 2011, 05:31 PM
Hi Atanas!

While prepering the sample project a found the bug.
The problem was within the "ClientTemplate" parameter - a link for ajax. I mixed things up around inside there.
Was:
.ClientTemplate("<a href='"
+ Url.Action("Edit", "InternalProposal")
+
"/<# id_main #>Edit</a>"
" | <a href='"
+ Url.Action("Details", "InternalProposal")
+
"/<# id_main #>Details</a>");

Should be 
.ClientTemplate("<a href='"
+ Url.Action("Edit", "InternalProposal")
+
"/<#=id_main#>'>Edit</a> "
"| <a href='"
+ Url.Action("Details", "InternalProposal")
+
"/<#=id_main#>'>Details</a>")

Thank you

Best Regards,
Szymon
0
Forest
Top achievements
Rank 1
answered on 17 Jun 2011, 05:19 PM
I'm having this same exact issue.  It works fine outside of Ajax, but when I try to use Ajax, I get the same: Error! The requested URL returned 500 - error. 

Just downloaded the extensions today fro Nuget.  I will support a ticket with my sample project if this is not a known bug.  Please advise.     
Tags
Grid
Asked by
Szymon
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Szymon
Top achievements
Rank 1
Forest
Top achievements
Rank 1
Share this question
or