Diana Dimitrova
Diana Dimitrova

Reputation: 135

MVC3 Empty model on post

I have model which has data. The i create form with only on button, i don't use the model's data in there. When i press the button it goes correctly to the HTTPPOST method but the model is completely empty.

HTML:

@model ViewModels.RequestDeletionViewObject
@using (Html.BeginForm())
  {
     <input type="submit" value="submit"/>
  }

The RequestDeletionViewObject:

public class RequestDeletionViewObject : ViewModelBase 
    { 
        public TreeGridData NodeFilespacesData { get; set; } 
        public Dictionary<long, string> EmailList{ get; set; } 
    }

Controller:

public ActionResult RequestDel() 
        { 

            return View(_businessLogic.GetData()); 

        } 

        [HttpPost] 
        public ActionResult RequestDel(RequestDeletionViewObject model)  
        { 
            return View(_businessLogic.GetData());  
        }    

Please help me, I have done similar thing in many other places and it worked there, but not here, i don't know what am i missing? Thanks

Upvotes: 1

Views: 1010

Answers (1)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93464

You don't have any form controls in your form. A form will only post data that is in a form control (textbox, hidden field, checkbox, etc..)

It doesn't matter what data you send to the view, it will only post back data in form controls within the form.

Upvotes: 2

Related Questions