I have a view where I initially used Html.BeginForm(). After POSTing, I show a message with ViewData["Message"]. That works fine.
When I change to Ajax.BeginForm(), ViewData["Message"] is null.
What am I missing?
I have a view where I initially used Html.BeginForm(). After POSTing, I show a message with ViewData["Message"]. That works fine.
When I change to Ajax.BeginForm(), ViewData["Message"] is null.
What am I missing?
I guess when you use Html.BeginForm your controller is rendering the current View again, so the html will have the message correctly displayed.
When you make Ajax requests is up to you to control what should happen after the request success.
This can be done with the Ajax.BeginForm ajaxOptions parameter, where you can set a javascript callback function at the OnSuccess property.
FWIW, I was just plain doing this wrong. What I wanted to accomplish, and how to, is explained here - http://davidhayden.com/blog/dave/archive/2009/05/19/ASPNETMVCAjaxBeginForm.aspx