0

I have a view that executes HttpPost.

It is working fine as long as I have just textboxes. I have added a datetime picker and dropdown lists, the form is automatically getting posted onclick of datetime picker and dropdowns. I cannot even see the datetime picker and dropdown list details, they just appear and disappear and form posts and it is showing required error messages.

The datetime picker and dropdowns are created using jquery widget.

can somebody advise how to stop automatic posting of form in MVC4?

below is my view:

@using P.B.O
@model O

 @using (Html.BeginForm("Create", "O", FormMethod.Post))
 {

@Html.ValidationSummary(true)
<fieldset>
    <legend>Create a New Organization</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.C) 
        @Html.TextBoxFor(model => model.C, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.C) 
    </div> <br />

    <div class="editor-label">
        @Html.LabelFor(model => model.N)
        @Html.TextBoxFor(model => model.N, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.N)
    </div> <br />

    <div class="editor-label">
        @Html.LabelFor(model => model.D)
        @Html.TextBoxFor(model => model.D, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.D)
    </div> 

    <div>
        <label for="check" class="chk">
            Del ?
            <input id="IsSoftDeleted" name="IsSoftDeleted" data-val-required="The Del? field is required." data-val="true" type="checkbox" class="check"  />
        </label>
    </div>

    <br />

  <input id="FromDate" name ="FromDate" data-val="true" type="datetime" class="datetime" />

        <input type="submit" value="Create" />
</fieldset>

}

mmssaann
  • 1,507
  • 6
  • 27
  • 55
  • 1
    Please add your JavaScript code as well – haim770 Jun 27 '13 at 08:07
  • I have fixed it by adding type=button in jquery from answers http://stackoverflow.com/questions/932653/how-to-prevent-buttons-from-submitting-forms – mmssaann Jun 27 '13 at 08:12
  • I have fixed it by adding type=button in jquery from answers http://stackoverflow.com/questions/932653/how-to-prevent-buttons-from-submitting-forms – mmssaann Jun 27 '13 at 09:23

0 Answers0