tags:

views:

14062

answers:

2

How would I go about adding enctype="multipart/form-data" to a form that is generated by using <% Html.BeginForm(); %>?

+36  A: 

As part of htmlAttributes,e.g.

Html.BeginForm(action,controller, FormMethod.Post, new { enctype="multipart/form-data"})

liggett78
Just as a note, you can pass null for action and controller to get the same default target that BeginForm() without parameters gives.
cantabilesoftware
+8  A: 

You can also use the following syntax for the strongly typed version:

<% using (Html.BeginForm<SomeController>(x=> x.SomeAction(), 
          FormMethod.Post, 
          new { enctype = "multipart/form-data" })) 
   { %>
dp
Can't do this in the current version (RC1).
Jason Bunting
Which is a massive bummer :( So how can we do this? do we need another dll? MVC futures or something?
Pure.Krome
Yes, indeed...I believe all of the strongly typed (expression-based) methods are in the futures assembly (http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471).
dp