---
title: "Model nested type is null when after modelbinding"  
description: "Model nested type is null when after modelbinding"  
author: "Anonymous User"  
published: 2013-04-03  
updated: 2013-04-03  
canonical: https://www.mindstick.com/forum/701/model-nested-type-is-null-when-after-modelbinding  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# Model nested type is null when after modelbinding

Hi Everyone!\
I have a [ViewModel](https://www.mindstick.com/forum/157215/what-is-viewmodel-in-mvc) as below:\
public class CheckoutViewModel{ public string ProductNumber { get; set; } public string Name { get; set; } public int Price { get; set; } public Input UserInput;\
public class Input { public string Email { get; set; } public string Phone { get; set; } }}And an action like this:\
[HttpPost]public [ActionResult](https://www.mindstick.com/forum/33961/what-is-the-difference-between-actionresult-and-viewresult) Index(CheckoutViewModel model){ // ... return View();}And my model has bound as below:\
@model GameUp.WebUI.ViewModels.CheckoutViewModel\
@using ([Html.BeginForm](https://www.mindstick.com/forum/1944/html-beginform-post-going-to-httpget-action-rather-than-httppost-in-ie-fine-in-chrome-and-firefox)("Index", "Checkout", FormMethod.Post)){ @[Html.AntiForgeryToken](https://www.mindstick.com/interview/34225/how-to-call-html-antiforgerytoken-in-asp-dot-net-web-api)()\
<!-- some HTML -->\
@Html.LabelFor(m => m.UserInput.Email) @[Html.TextBoxFor](https://www.mindstick.com/forum/33953/what-is-the-difference-between-html-textbox-vs-html-textboxfor)(m => m.UserInput.Email)\
@Html.LabelFor(model => model.UserInput.Phone) @Html.TextBoxFor(model => model.UserInput.Phone)\
<button>Submit</button>}When I submit the form, the UserInput is null. I know [ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) is able to bind nested types but in this code is not. Also I can get the Email and Phone \
values by:\
var email = [Request.Form](https://www.mindstick.com/forum/12799/handling-an-a-potentially-dangerous-request-form-value-was-detected-exception-without-deactivating-validation)["UserInput.Email"];var phone = Request.Form["UserInput.Phone"];Maybe I do [something wrong](https://www.mindstick.com/forum/12790/something-wrong-with-gridview)! It's a simple [model binding](https://www.mindstick.com/forum/158590/what-is-model-binding-in-asp-dot-net-mvc-and-how-does-it-work) you can find [everywhere](https://yourviews.mindstick.com/view/80697/bjp-losing-ally-everywhere) in the web.\
Thanks in advance!\

## Replies

### Reply by AVADHESH PATEL

Hi Jeet!\
change your properties as from below line of code \

```
public class CheckoutViewModel{    public string ProductNumber { get; set; }    public string Name { get; set; }    public int Price { get; set; }    public Input UserInput { get; set; }    public class Input    {        public string Email { get; set; }        public string Phone { get; set; }    }}
```

\
I hope it resolve your problem


---

Original Source: https://www.mindstick.com/forum/701/model-nested-type-is-null-when-after-modelbinding

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
