Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ryan Groene 9 posts 29 karma points
    Apr 17, 2012 @ 22:34
    Ryan Groene
    0

    values in page not posting to model in view

    I mentioned this problem in my other thread, but since it's a different problem, I thought it should have its own thread. I am trying to get a surface controller to work, and I have a view (rendered using Html.Action), which contains a form (Html.BeginUmbracoForm). When I submit this form, it posts back (correctly) to my processFormData function in my controller, but it doesn't seem to have the model data (everything is null).

    My method is as follows:

    [HttpPost]
    public ActionResult processFormData(Contact model)
    {
    //processing logic


    Contact is a simple object that I placed in the Models directory.

    I'm rendering the view using a shared view, rendered using Html.Action, which uses Html.BeginUmbracoForm with the name of my controller and the method to post to. At the top I have

    @inherits System.Web.Mvc.WebViewPage<MyProject.Model.Contact>

  • Ryan Groene 9 posts 29 karma points
    Apr 17, 2012 @ 23:36
    Ryan Groene
    0

    I fixed this. It was just because I didn't add getters or setters to the properties of my model. Normally, I would do this when building a class, but I was trying to keep it simple for testing purposes and didn't realize they were required for this to work properly. I'm fairly new to .NET MVC in general. I did one project with MVC 2 a while back (after which came several months of PHP programming without touching .NET). So, anyway, it was a pretty simple fix.

Please Sign in or register to post replies

Write your reply to:

Draft