Ramco Ramco

Ramco Ramco

  • 1.6k
  • 310
  • 8.9k

ModelState Error

Jun 8 2021 2:05 AM

Hi

   IN below code when ModelState is false i want that Modal Popup should remain open so that user can make changes . But according to my code it shows error and then View opens since in have written 

return RedirectToAction("Index"). How it can be done that Modal Popup should remain open if ModelState is false

***************************************************************************

<div class="modal fade" id="myModal"tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">Add New Location</h4>
            </div>
            <div class="modal-body">
                <div class="form-horizontal">
                    <div class="form-group">
                        <label class="control-label col-sm-3" for="Id">Id</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control form-control-sm" id="txtId" placeholder="Id">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3" for="Description">Description</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control form-control-sm" id="txtDescription" placeholder="Description">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3" for="Active">Active</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control form-control-sm" id="txtActive" placeholder="Active">
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();">Save</button>
                <button type="button" class="btn btn-primary" id="btnUpdate" style="display:none;" onclick="Update();">Update</button>
                <button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>

 

Thanks

 


Answers (1)