Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jordan Lane 28 posts 130 karma points c-trib
    Jul 23, 2013 @ 18:31
    Jordan Lane
    0

    Cannot set class on form using Html.BeginUmbracoForm in MVC

    So I'm trying to add a class to the form element and the form is generated using the following code:

    @using(Html.BeginUmbracoForm<SearchFormSurfaceController>("HandleSearchForm"))

    I've tried doing the following: 

    @using(Html.BeginUmbracoForm<SearchFormSurfaceController>("HandleSearchForm", new { @class = "myclass" }))

    This doesn't throw any errors however doesn't add a class to the form element.

    To add a class to a label for example is easy: 

    @Html.LabelFor(model => model.Weight, new { @class = "myclass" })

    Thanks.

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 23, 2013 @ 18:39
    Dirk De Grave
    109

    you're using the wrong overload, if passing 2 params, 2nd is supposed to route values, so, you must use

    @using(Html.BeginUmbracoForm<SearchFormSurfaceController>("HandleSearchForm", null, new { @class = "myclass" }))

    Cheers,

    /Dirk

  • ibrahim TUNC 55 posts 133 karma points
    Jul 18, 2016 @ 07:49
    ibrahim TUNC
    0

    Thanks for answer Dirk.

  • Jordan Lane 28 posts 130 karma points c-trib
    Jul 23, 2013 @ 18:44
    Jordan Lane
    0

    Doh! Thank you very much.

    Is there documentation that lists arguments etc? Sorry I'm just getting started with MVC.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 23, 2013 @ 18:46
    Dirk De Grave
    0

    I know of http://our.umbraco.org/documentation/Reference/Mvc/, haven't seen anything better than this

    Anyway, it was Resharper helping me out here!

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft