0

I used either form or Ajax.beginform to create a DNN module, In both cases after installing module, The submit click causes jump to top of the page.

I tried using jquery preventdefault and return false in submit button click but had no good effect.

How to correct this in DNN and MVC?

Code:

@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage<MyModule2.Models.TestFormModel>
@using System.Web.Mvc.Ajax
@{
    ViewBag.Title = "TestFormv";
    Layout = "../shared/_Layout.cshtml";
}


<form action="testform" method="post" id="frmTest">
    @Html.ValidationSummary(false, "", new { @class = "text-danger" })
    <div class="form-group d-flex flex-md-row align-items-center">
        @Html.LabelFor(m => m.Name, new { @class = "form-label mr-2" })
        @Html.TextBoxFor(m => m.Name, new { @class = "form-control mr-2" })
        @Html.ValidationMessageFor(m => m.Name, null, new { @class = "" })
        <input type="submit" value="Submit" class="btn btn-primary" id="submit" />
    </div>
</form>
mz1378
  • 1,957
  • 4
  • 20
  • 40

1 Answers1

0

Could use CSS to force a min-height for the container/div, stopping the content shifting after the elements load. Without a code snippet, it is only a guess/workaround

  • hi, using code above clicking submit button refreshes the page to get a correct result, but when page comes backs scroll position is not maintained. and page is at top. – mz1378 Jun 22 '23 at 11:58