2

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.

tereško
  • 58,060
  • 25
  • 98
  • 150
mandy
  • 37
  • 1
  • 3

3 Answers3

5

You could just add padding to the parent div.

<div class="mdl_bdy_frm" style="padding-top:20px;">

Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86
3
Html.BeginForm( ..., ..., ..., New With {.style = "margin-top:20px;"})

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

Community
  • 1
  • 1
Dor
  • 7,344
  • 4
  • 32
  • 45
1
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { style = "margin: 10px;" }))
Mehdiway
  • 10,337
  • 8
  • 36
  • 68