Search code examples
cssasp.net-mvchtml-helper

How can I apply a top margin to my Html.BeginForm


I have this code:

<div class="mdl_bdy_frm">
   @using (Html.BeginForm())
            {

            @Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") 

            @Html.LabelFor(m => m.Login.UserName, new { @class = "adm" })
            @Html.TextBoxFor(m => m.Login.UserName, new { @class = "adm", size = 30 })
            @Html.ValidationMessageFor(m => m.Login.UserName)

            @Html.LabelFor(m => m.Login.Password, new { @class = "adm" })
            @Html.PasswordFor(m => m.Login.Password, new { @class = "adm", size = 30 })
            @Html.ValidationMessageFor(m => m.Login.Password)
            <br />
            @Html.CheckBoxFor(m => m.Login.RememberMe, new { @class = "adm" })
            @Html.LabelFor(m => m.Login.RememberMe, new { @class = "adm" })

            <p><input type="submit" value="Login" /></p>

        }
</div>

Is there a way that I can give my HTML.BeginForm at top-margin style? If possible I would like to do this with an inline style as its just used in the one place.


Solution

  • Html.BeginForm( ..., ..., ..., New With {.style = "margin-top:20px;"})
    

    See: How to add id HTML attribute in ASP.NET MVC w/ VB.NET