MVC Preview 5 and Html.Form() and "multipart/form-data"

Last post 09-10-2008 2:14 AM by panik. 2 replies.

Sort Posts:

  • MVC Preview 5 and Html.Form() and "multipart/form-data"

    09-07-2008, 11:22 AM
    • Member
      2 point Member
    • panik
    • Member since 06-26-2008, 3:16 AM
    • Gent
    • Posts 7

    Hi,

    I'm changing a project which I use to learn to use ASP.NET MVC from Preview 4 to 5. Now that you have the [ActionName()] attribute, I changed my controller code and of course my views. In Preview 4 I 'declared' the <form/> tag using Html.Form with the necessary parameters. That came in handy to add the enctype = "multipart/form-data" attribute to the <form/> tag.

    But Preview 5 has no overload for Html.Form() that I can use.

    How can I force the enctype attribute into my form?

    Cheers,
    v

    Do not break the web
  • Re: MVC Preview 5 and Html.Form() and "multipart/form-data"

    09-07-2008, 11:54 PM
    • Contributor
      4,372 point Contributor
    • tgmdbm
    • Member since 12-17-2007, 2:08 PM
    • Posts 883
    • ASPInsiders
      TrustedFriends-MVPs

     what about the Html.Form<T>(Expression<Action<T>> postAction, FormMethod method, object htmlAttributes) overload?

    <% using Html.Form<ProductController>( c => c.Update(), FormMethod.Post, new { enctype = "multipart/form-data" } ) { %> 

     

  • Re: MVC Preview 5 and Html.Form() and "multipart/form-data"

    09-10-2008, 2:14 AM
    • Member
      2 point Member
    • panik
    • Member since 06-26-2008, 3:16 AM
    • Gent
    • Posts 7

     Hi,

    Thanks for answering, but that was the method signature I called when using Preview 4. As that was the only way to do it (as far as I remember). Now, calling simply Html.Form() is great because MVC does all the plumbing itself (defining the controller, the action, on which I added the AcceptsVerbs and ActionName attributes). The only thing I want to add to the Html.Form() is one or two html attributes.

    v

     

    Do not break the web
Page 1 of 1 (3 items)