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

Razor AJAX update as Post

3 Answers 111 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Roderick Prince
Top achievements
Rank 1
Roderick Prince asked on 22 May 2014, 11:18 PM
The Update request below is being sent as an HttpGet - how do you change the transport to indicate that it should be a post?

@(Html.Kendo().Scheduler<CIC.Web.UI.Models.TaskViewModel>()
    .Name("scheduler")
    .Date(DateTime.Now)
    .StartTime(DateTime.Now)
    .ShowWorkHours(true)
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WorkWeekView(workWeekView => workWeekView.Selected(true));
        views.WeekView();
        views.MonthView();
        views.AgendaView();
    })
    .Editable(editable =>
    {
        editable.TemplateName("_EditorForEventTemplate");
    })
    .Events(e =>
    {
        e.Edit("scheduler_edit");
        e.Change("scheduler_change");
    })
    .DataSource(d => d
        .Model(m =>
        {
            m.Id(f => f.TaskID);
            m.Field(f => f.Title).DefaultValue("New Event");
            m.Field(f => f.SponsorID);
            m.Field(f => f.ContactEMail);
        })
        .Events(e => e.Error("error_handler"))
        .ServerOperation(true)
        .Read(read => read.Action("Events_Read", "Home").Data("getAdditionalData"))
        .Create("Events_Create", "Home")
        .Destroy("Events_Destroy", "Home")
        .Update("Events_Update", "Home")
    )
    .Resources(resource =>
    {
        resource.Add(tvm => tvm.SponsorID)
            .Title("CompanyName")
            .DataTextField("DBAName")
            .DataValueField("CompanyID")
            .DataSource(ds => ds.Read(read => read.Action("GetSponsors", "Home")));

        resource.Add(tvm => tvm.EventType)
            .Title("Description")
            .DataTextField("Description")
            .DataValueField("Code")
            .DataSource(ds => ds.Read(read => read.Action("GetEventTypes", "Home")));
    })
    
)

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 May 2014, 06:27 AM
Hi Roderick,

As you may know the default verb used by the Scheduler widget of UI for ASP.NET MVC is POST. However, you should verify that you have correctly setup the script references and the kendo.aspnetmvc.min.js file is included. Information on how to setup the ASP.NET MVC project can be found in the following help articles depending on the version used:

Kendo UI in ASP.NET MVC 3 applications
Kendo UI in ASP.NET MVC 4 applications
Kendo UI in ASP.NET MVC 5 applications


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Roderick Prince
Top achievements
Rank 1
answered on 23 May 2014, 07:58 PM
Rosen,

If I am not mistaken I would not be in a position to be concerned about how it is posting data back to the site if the js file references were not in place. I did confirm that the site is configured per your links. So to return to my question, the update request is occurring via an HttpGet when it should be via an HttpPost - how can I change the routing?

Note if I have the [HttpPost] attribute on my controller action I get a 404 error and see from the Request Headers in fiddler that it attempted the request via GET.

0
Rosen
Telerik team
answered on 26 May 2014, 06:24 AM
Hi Roderick,

As I have mentioned in my previous post, the default verb for all CRUD operations of the ASP.NET MVC Scheduler wrapper is POST. Therefore, sending a GET request most probably signals for incorrect configuration. Could you please provide a small runnable sample which exhibits the behavior in question. This will allow us to get better understanding about your configuration and provide you with more to-the-point answer.

You can change the verb via the DataSource -> Update action configuration:

.DataSource(d => d
     /*..*/
     .Update(update => update.Action("Update", "Scheduler").Type(HttpVerbs.Post))
 )

However, note that if kendo.aspnetmvc.min.js is missing or not correctly referenced, the updates will still not work as expected.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
Roderick Prince
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Roderick Prince
Top achievements
Rank 1
Share this question
or