none
Razor : How to set two buttons inline if they are in different forms RRS feed

  • Question

  • Hi there,

    I have two button in different forms and I would like to put them inline. Because a security requirement they can't be in the same form.

    This is the code:

    <div style="display:inline">
        @using (Html.BeginForm("x", "x", new { style = "display:inline" }))
        {
     
            <input type="submit" value="Get Policy Value" class="btn btn-primary min-width-115" style="display:inline" />
        }
        @using (Html.BeginForm("Detail", "Policy", FormMethod.Post, new { policyNumber = Model.PolicyNumber, style = "display:inline" }))
        {
            <button class="btn btn-orange min-width-115" type="submit">Cancel</button>
        }
    </div>

    • Moved by CoolDadTx Tuesday, March 10, 2020 5:40 PM ASP.NET related
    Tuesday, March 10, 2020 5:36 PM

All replies

  • Please post questions related to ASP.NET, MVC and Razor in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, March 10, 2020 5:39 PM
  • Thanks for that.

    Regards,

    Alvaro

    Wednesday, March 11, 2020 9:33 AM
  • Use the code similar to this to get the buttons inline.

    <form>
        <div class="col-md-4">
            <div class="form-group">
                @Html.LabelFor(model => model.InterestName)
                @Html.EditorFor(model => model.InterestName, new { htmlAttributes = new { @class = "form-control" } })
            </div>
        </div>
        <div class="col-md-4">
             <div class="form-group">
                @Html.LabelFor(model => model.Description)
                @Html.EditorFor(model => model.Description, new {  htmlAttributes = new { @class = "form-control" } })
             </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                  <button type="submit" class="btn btn-default" style="margin-">Add</button>
            </div>
         </div>
    </form>

    Regards.

    Wednesday, March 11, 2020 10:06 AM
  • the point is i need two forms, because the button are a submit button type.

    If they are in the same form, the behavior is working wrong.

    Wednesday, March 11, 2020 12:36 PM