tags:

views:

57

answers:

2

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?

A: 

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.

You are correct that the current View is rendered again. And indeed I needed to add the new AjaxOptions{,,,} when I changed to Ajax.BeginForm().The JavaScript code I copied/pasted did not take any args for the OnSuccess function I have it call, so while that JS function gets called, I have no idea how to accomplish what I'm looking for.Maybe I'm missing something once again?
Mike Hildner
A: 

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

Mike Hildner