I am having a simple grid with a ajax binding and one of the column is a drop down. When I try to insert a new record in the grid, the AntiforgeryToken is not passed to the controller. I am setting token on OnDataBinding event.
I am running on version 2011.1.315. Any help is greatly appreciated. I even tried couple of alternatives like tried to add an input control to the form on onsave event, this didn't help either, I don't know how to add the token to e.values on onsave event.
Any suggestions?
Thank you,
mm
9 Answers, 1 is accepted
I created a sample project showing how to do send the antiforgery token via the OnSave event. Here is the relevant code:
<%: Html.AntiForgeryToken() %><%: Html.Telerik().Grid<GridAntiForgeryToken.Models.Customer>() .Name("Grid") .DataKeys(keys => keys.Add(c => c.ID)) .Columns(columns => { columns.Bound(c => c.ID).ReadOnly().Width(100); columns.Bound(c => c.Name); columns.Command(c => c.Edit()).Width(200); }) .ClientEvents(e => e.OnSave("onSave")) .DataBinding(dataBinding => dataBinding.Ajax().Select("Select", "Home").Update("Update", "Home"))%><script>function onSave(e) { // anything added to e.values will be submitted to the server e.values["__RequestVerificationToken"] = $("input[name=__RequestVerificationToken]").val();}</script>Atanas Korchev
the Telerik team
Thank you,
mm
Unfortunately in its current implementation it is not possible to pass additional parameters through grid's delete client-side event. However, we were able to address this limitation and this will be possible with the next internal build.
Meanwhile, I have attached a modified version of telerik.grid.editing.js file for your convenience. I have also updated you telerik points.
Rosen
the Telerik team
I just replaced the script file you sent me, did I miss anything.
Thank you for your help.
Murali.
I have attached a modified version of the sample my colleague Atanas provided. Please give it a spin, maybe I'm missing something obvious.
Regards,Rosen
the Telerik team
I have tried version 414 and the patch you have sent me, unfortunately I am not able to run your sample project as it is MVC3, I get the following error.
Cannot set property '__RequestVerificationToken' of undefined
I have looked at the files from your sample and copies the files over, but still get the same error, when I step through the debugger I don't see values property on e.
Any help is greatly appreciated.
Thank you,
mm
This means that the upgrade was not properly done. Please check this help article which outlines the required steps.
Regards,Atanas Korchev
the Telerik team
I have gone through the steps again, and still have no luck.
All other features of the grid, tab and other Telerik components are working so I don't think I messed anything up with the upgrade.
Thank you,
Murali.
Provided that the last sample project which we attached works as expected I am not sure what went wrong. Did you replace the telerik.grid.editing.min.js file with the one attached previously? It seems you have not.
We have also included this fix in our latest internal build which you can download and try.
Atanas Korchev
the Telerik team