ASP.NET MVC 2 - ViewData empty after POST?

ViewData is relevant when going from the controller to the view. It won't post back you'll need your action method to look something like public ActionResult DoSomething(string data1, string data2, int data3) { Then the (model? Parameter?) binding should take care of things for you.

ViewData is relevant when going from the controller to the view. It won't post back. You'll need your action method to look something like public ActionResult DoSomething(string data1, string data2, int data3) { ... Then the (model?

Parameter? ) binding should take care of things for you.

... Exactly :-) – Darin Dimitrov May 28 '10 at 19:15.

Try modifying your Action to accept FormCollection: public ActionResult DoSomething(FormCollection fc) { System.Diagnostics.Debug. Writeline(fc"data1"); }.

If you want to see what is posted to your View, accept FormCollection as a parameter, or bind your form elements directly to a model. Like so: AcceptVerbs(HttpVerbs. Post) public ActionResult PostToThisView(FormCollection formItems) { var data1 = formItems"data1"; return View(); } Also, see this question.

Try this: Request"data1" or Request. Form"data1" or HttpPost public ActionResult YourPostAction(object data1) or HttpPost public ActionResult YourPostAction(ACLassThatHasData1Prop viewmodel) //your view doesn't has to be strongly typed to the type of the parameter in this case.

Regarding the last example, the model used for the parameter doesn't have to be the same as the model that is strongly-typed to the view from which the request came. The model binder will simply take the values stored in the forms collection (or the query string if the request is a GET) and try to used them to populate whatever type of object is specified as the parameter. – Dr. Wily's Apprentice May 28 '10 at 20:36 @Dr. Wily's Apprentice, thnx for telling me that – Chuck Norris May 29 '10 at 8:19.

ViewData is empty, there is no ViewData"data1" or anything else that would show that data arrived. How can this be? Where can I start looking for the error?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions