title: How to get the value of dynamically created textbox on HttpPost
body: <p>I am creating <code>Textbox</code> control Dynamically as following, but on <code>HttpPost</code> it is not returning anything back. I am expecting the value of textbox to be accessible in Controller on <code>HttpPost</code>. Can anyone please suggest me how I can achieve this. Thanks</p>
  
  <p><strong>Models</strong></p>
  
  <pre><code>public class MyViewModel
  {
      public ControlViewModel[] Controls { get; set; }
  }
  
  public abstract class ControlViewModel
  {
      public abstract string Type { get; }
      public bool Visible { get; set; }
      public string Label { get; set; }
      public string Name { get; set; }
  }
  
  public class TextBoxViewModel : ControlViewModel
  {
      public override string Type
      {
          get { return "textbox"; }
      }
      public string Value { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult Index(Guid? id)
  {
      return Results(id);
  }
  
  [HttpPost]
  public ActionResult Index(MyViewModel model)
  {
      // Logic here
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Site.master"
   Inherits="System.Web.Mvc.ViewPage&lt;MySite.Model.ViewModels.MyViewModel&gt;" %&gt;
  
  &lt;div&gt;
      &lt;% using (Html.BeginForm("Index", "MyController", FormMethod.Post, null))
      { %&gt;
          &lt;% for (int i = 0; i &lt; Model.Controls.Length; i++)
             { %&gt;
                 &lt;%Html.RenderPartial("TextboxControl", (TextBoxViewModel)Model.Controls[i]); %&gt;             
          &lt;% } %&gt;
          &lt;input type="submit" value="Submit" class="btn btn-primary"/&gt;       
      &lt;% } %&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p><strong>UserControl</strong></p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;MySite.Model.ViewModels.TextBoxViewModel&gt;" %&gt;
  &lt;div&gt;
       &lt;%
             var controlType = Model.Type;
             var controlName = Model.Name;               
       %&gt;
       &lt;%= Html.TextBoxFor(x =&gt; x.Value, new { id = controlName, type = controlType, @class = "input-medium" })%&gt;
  &lt;/div&gt;
  </code></pre>