tags:

views:

218

answers:

1

Hi,

On a view, i have a partial view rendering an ajax form that allows me to create a new element. On the same view, i have a partial control that list the elements already in the database.

My create action will redirect the the list action if everything is ok or to the create action with an error message if something is wrong with the user data.

Actually it is working when everything is ok: the list is updated. However, how could I change the updatetargetid with the onfailed attribute?

Thanks.

A: 

Finally I have found the solution:

In the ajaxOption of the Ajax.BeginForm, i have to put a function for the onsuccess event that will perform an ajax update of the desired element, and another function that updates another element for the onFailure event

In the controller, I have to return an empty result if the request is ok, else, I have to return the content with request status of HttpStatusCode.BadRequest, so the onFailure update the right element

Gregoire