2016-11-30 2 views
1
@Html.ActionLink("edit", "Edit", "MedQuantityType", new { id = item.Med_quan_typeId }, new 
        { 
         @* Needed to link to the html of the modal*@ 
         data_target = "#mymodel", 
         @* Tells the bootstrap javascript to do its thing*@ 
         data_toggle = "modal", 
        }) 

Dies ist die Aktion Link Ich versuche Teilansicht in Bootstrap-Modell Popup, es funktioniert gut, wenn ich versuche & zu bearbeiten, speichern Sie es außer Modellzustand funktioniert, ist nicht gültig hier mein Controller CodePopup Teilansicht in einem Bootstrap-Modell Popup

public async Task<ActionResult > Edit([Bind(Include = "Med_quan_typeId,Med_quan_type,Med_quantity")] Med_quantity_type med_quantity_type) 
{ 
    if (ModelState.IsValid) 
    { 
     db.Entry(med_quantity_type).State = EntityState.Modified; 
     await db.SaveChangesAsync(); 
     return RedirectToAction("Index"); 
    } 

    return PartialView(med_quantity_type); 
} 

Wenn mein Modellzustand in MyModel die Steuerung Rückkehr Teilansicht aber es ist nicht popup nicht das ist meine Teilansicht cshtml Seite

<div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 
       <span aria-hidden="true">&times;</span> 
      </button> 
      <h4 class="modal-title">Medicine Quantity Type - Edit</h4> 
     </div> 
     <div class="modal-body"> 
@using (Ajax.BeginForm("Edit", "MedQuantityType", 
      new AjaxOptions 
      { 
       HttpMethod = "GET", 
       InsertionMode = InsertionMode.Replace, 
       UpdateTargetId = "mymodel" 
      })) 
      { 
       @Html.AntiForgeryToken() 

       <div class="form-horizontal"> 
        @Html.ValidationSummary(true) 
        @Html.HiddenFor(model => model.Med_quan_typeId) 

        <div class="form-group"> 
         <div class="col-md-3 col-md-offset-1"> 
          @Html.LabelFor(model => model.Med_quan_type, new { @class = "control-label " }) 
         </div> 
         <div class="col-md-6"> 
          @Html.TextBoxFor(model => model.Med_quan_type, new { @class = "form-control", @id = "txtquantype" }) 
          @Html.ValidationMessageFor(model => model.Med_quan_type) 
         </div> 
        </div> 

        <div class="form-group"> 
         <div class="col-md-3 col-md-offset-1"> 
          @Html.LabelFor(model => model.Med_quantity, new { @class = "control-label" }) 
         </div> 
         <div class="col-md-6"> 
          @Html.TextBoxFor(model => model.Med_quantity, new { @class = "form-control" }) 
          @Html.ValidationMessageFor(model => model.Med_quantity) 
         </div> 
        </div> 
       </div> 

       <div class="modal-footer"> 
          <input type="submit" value="Save" class="btn btn-success" id="btnsubmit" />      
          <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button> 
        </div> 

       <div ID ="popupform"class="popover"> 
        <div class="alert-danger"> Please Fix The errors </div> 

       </div> 
      } 
     </div> 
    </div> 
</div> 

<script type="text/javascript"> 

    $(document).ready(function() { 
     $(function() { 
      debugger; 
      // when the modal is closed 
      $('#mymodel').on('hidden.bs.modal', function() { 
       // remove the bs.modal data attribute from it 
       $(this).removeData('bs.modal'); 
       // and empty the modal-content element 
       $('#mymodel .modal-content').empty(); 
      }); 
     }); 
    }); 

    </script > 

Bitte helfen Sie jemand, wie Teilansicht Popup, sobald Controller

+0

Würden Sie das Szenario erklären und sagen, was genau passiert und was nicht? Ihre Frage ist ein wenig unklar –

Antwort

0

Von Task<ActionResult >-Task<PartialViewResult> Teilansicht zurückzukehren dann ActionLink-RenderPartial ändern.

Es sollte gut funktionieren.

+0

Vielen Dank, es funktioniert gut – christopher

0

Ändern der Rückgabetyp Ihrer Aktion zu Task<PartialView>