title: How to send data from view to controller action in asp.net mvc?
body: <p>I developed a custom HtmlHelper extension method but that data is not
  posting Action.</p>
  
  <p><strong>HtmlHelper extension class:</strong></p>
  
  <pre><code>public static class TestHtmlHelper
  {
      public static MvcHtmlString CreateControl(this HtmlHelper helper, string tagName, IDictionary&lt;string, string&gt; attributes)
      {
          var newTag = new TagBuilder(tagName);
          newTag.MergeAttributes(attributes, true);
  
          return  MvcHtmlString.Create(newTag.ToString(TagRenderMode.Normal));
      }
  
      public static string Image(this HtmlHelper helper, string id, string url, string alternateText, object htmlAttributes)
      {
          // Create tag builder
          var builder = new TagBuilder("img");
  
          // Create valid id
          builder.GenerateId(id);
  
          // Add attributes
          builder.MergeAttribute("src", url);
          builder.MergeAttribute("alt", alternateText);
          builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
  
          // Render tag
          return builder.ToString(TagRenderMode.Normal);
      }
  
  }
  </code></pre>
  
  <p><strong>//View code</strong></p>
  
  <pre><code> @using (Html.BeginForm("Go","Home",FormMethod.Post))
  {
      IDictionary&lt;string, string&gt; d = new Dictionary&lt;string, string&gt;();
      d.Add("type", "text");
      d.Add("id", "text1");
      d.Add("required", "required");
      @Html.Raw(Html.CreateControl("input", d))
      @Html.Raw(Html.Image("image1", "/Images/bullet.png", "bullet", new { border = "4px" }))
      d = null;
      d = new Dictionary&lt;string, string&gt;();
      d.Add("type", "submit");
      d.Add("value", "Go");
      @Html.Raw(Html.CreateControl("input", d))
      &lt;span&gt;&lt;/span&gt;
      d = null;
      d = new Dictionary&lt;string, string&gt;();
      d.Add("value", "text");
      d.Add("id", "span1");
      d.Add("text", "required");
      @Html.Raw(Html.CreateControl("span", d))
  }
  </code></pre>
  
  <p><strong>// Controller code</strong></p>
  
  <pre><code>public ActionResult Index()
  {
      ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
  
      return View();
  }
  [HttpPost]
  public ActionResult Go(string test)
  {
      return Content(test);
  }
  </code></pre>
  
  <p>I didn't get data in string test. I want to submit that data to DB.</p>