title: Regarding assigning model data to textbox in asp.net MVC
body: <p>i am new in MVC. i got a code and it was just about to populate viewdata from controller and pass it to view. just have look at the code.</p>
  
  <p><strong>controller</strong></p>
  
  <pre><code>public ActionResult Edit(int id)
          {
              ViewData["Name"] = "My name is XYZ";
              return View();
          }
  </code></pre>
  
  <p><strong>view page</strong></p>
  
  <pre><code>@Html.TextBox("Name")
  </code></pre>
  
  <p>my question is how textbox understand to extract name and display it as textbox value. basically name was stored in viewdata. first we need to extarct data from viewdata and then we can assign that data to textbox as value. how it works ?. </p>
  
  <p>some one explain but things is not very clear to me</p>
  
  <p>MVC is designed with default protocol to look for keywords and try to make associations to those keywords.  You've chosen to use 'Name' for a temporary data object.  MVC will then make an effort to look for any elements that have the same name.  it believes that you intended to assign the element the same name as your ViewData object because you want it associated.</p>
  
  <p>The same goes for ViewBag.  You can give a ViewBag a name (ViewBag.Name) and any time you use 'Name' for an element, MVC will automatically assume you want that element associated to the ViewBag data.  This works with lists too!</p>
  
  <pre><code>ViewBag.myList = db.Products.ToList();
  
  @Html.DropDownList("myList");
  </code></pre>
  
  <p>my understand about mvc flow is not very clear.i am new in mvc. so i am reading mvc tutorial. i am not very much convienced after reading the above answer. just think about asp.net web form. in asp.net web form</p>
  
  <p>if we store anything into viewstate or session like this way <code>viewstate["Name"]="Mou" or session["Name"]="Mou"</code> then we need render that value at client side like this way <code>&lt;asp:textbox value=&lt;% name %&gt;/&gt;</code> then i will get error but if we write like this way <code>&lt;asp:textbox value=&lt;% viewstate["Name"] as string %&gt;/&gt;</code> then it will work. so how MVC can understand if we specify simply <code>@Html.TextBox("Name")</code></p>
  
  <p>suppose name can be stored in session, viewdata, viewbag, tempdata etc so how MVC engine can resolve it ? looking for good explanation with more example.
  thanks</p>