title: Passing values between View and Controller in MVC 2
body: <p>I'm constantly confused about how to pass values between Views and Controllers in MVC. I know I can set ViewData in the Controller and use that in the View, but what about the other way around?</p>
  
  <p>What I have found is I can use a hidden field and then access it through Request.Form["name"] like this:</p>
  
  <pre><code>&lt;% using (Html.BeginForm("Upload", "Customers", FormMethod.Post, new { enctype = "multipart/form-data" }))
     {%&gt;
  &lt;br /&gt;
  &lt;input id="currentDir" type="hidden" name="currentDir" value="" /&gt;
  &lt;input type="file" name="fileTextbox" id="fileTextbox" /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;input type="submit" value="Send" /&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>What complicates it even more is that the value originally comes from a jquery script, so that's why the input field was the only way I could think of. But it still feels wrong... Maybe it isn't but I'd basically like to know if there are other more "proper" established ways to pass values between the View and Controller (both ways). Should one use querystrings instead? If so, how would they look in the html.beginform htmlhelper?</p>
  
  <p>Also, what I'm trying to do here is enable upload possibilities for my application. And I'm trying to make the whole application as "Ajaxy" as possible. But this form will make a complete post. Is there another way to do this and not have to reload the entire page for this upload?</p>