Ich habe folgende AnsichtMVC 5 Bearbeiten Bootstrap Modal Popup
@model QuotationManagement.Models.ProductViewModel
@{
ViewBag.Title = "Products";
}
<h2>Products</h2>
<button id='newProduct' data-toggle="modal" data-target="#newProductModal" class="btn btn-primary">Add New Product</button>
<br />
@using (Html.BeginForm("Products", "Main", FormMethod.Post, new { encType = "multipart/form-data", name = "myform" }))
{
<table class="table table-bordered table-condensed table-striped">
<tr>
<th>
Name
</th>
<th>
Price
</th>
<th>
Gender
</th>
<td>
Action
</td>
</tr>
@Html.EditorFor(model => model.Products)
</table>
}
<div id="newProductModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
@using (Html.BeginForm("NewProduct", "Main", FormMethod.Post, new { encType = "multipart/form-data", name = "newProdutForm", @class = "form-group" }))
{
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">New Product</h4>
</div>
<div class="modal-body">
@Html.HiddenFor(model => model.NewProduct.Id)
Name:
@Html.TextBoxFor(model => model.NewProduct.Name, new { @class = "form-control" })
Price:
@Html.TextBoxFor(model => model.NewProduct.Price, new { @class = "form-control" })
Gender:
@Html.DropDownListFor(model => model.NewProduct.ForGender, new List<SelectListItem>() { new SelectListItem() { Text = "Male", Value = "1" }, new SelectListItem() { Text = "Female", Value = "2" } }, new { @class = "form-control" })
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
}
</div>
</div>
</div>
Und dann die Vorlage
@model QuotationManagement.Bussiness_Logic_Layer.Product
<tr>
<td>
@Html.HiddenFor(model => model.Id)
@Html.DisplayFor(model => model.Name)
</td>
<td>
@Html.DisplayFor(model => model.Price)
</td>
<td>
@Html.DisplayFor(model => model.Gender)
</td>
<td>
@Html.ActionLink("Edit", "EditProduct","Main", Model ,new { @class = "btn btn-primary"})
</td>
</tr>
ein neues Produkt Werke hinzufügen, aber jetzt möchte ich auf die Schaltfläche Bearbeiten ändern das Binden row item zum Boostrap Popup und öffnet es dann zur Bearbeitung.
Die aktuelle Methode, die ich versuche, ist mit dem ActionLink, der dann das ausgewählte Produkt nimmt und es an ProductViewModel.NewProduct bindet, das funktioniert jetzt aber mein Problem ist, ich muss die ganze Seite neu laden und die Tabelle neu auffüllen und dann irgendwie Öffne das Boostrap Modal.
So ist meine Frage Wie kann ich das ausgewählte Produkt in den Modal binden und zeigen dann die Modal ein Postback tun withoud mit oder ohne die aktuelle Seite
sehe ich keinen Standardweg, dies zu tun, bis jetzt hatte. Dies ist flexibel genug, um ohne viel Modifikation in allen Situationen zu arbeiten, denen ich begegne. – sanepete
Ich habe eine kleine Änderung in Ihrem Javascript Teil Code, der für mich arbeitete, aber es funktionierte thanx –
hatte das gleiche Problem.aber löste es durch Hinzufügen der $ (function() { $ ('. EditModal'). Modal(); }); in den Erfolg Teil der Ajax-Methode. –