1
モーダルブートストラップ内に部分的なビューを作成して、フィールド値の編集ビューでテーブルに値を追加できるようにすることができますか?編集ビュー内でパーシャルビューを作成するにはどうすればよいですか?
私の部分図を作成
@model MVCLayout.Models.Table2
<p>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="form-group">
@Html.Label("Cargo: ", new { style = "width:160px" })
@Html.TextBoxFor(model => model.ID, new { style = "width:200px" })
</div>
<br/>
<div class="form-group">
@Html.Label("Percentual: ", new { style = "width:160px" })
@Html.TextBoxFor(model => model.Name, new { style = "width:200px" })
</div>
<br/>
<div class="form-group">
@Html.Label("Serviço: ", new { style = "width:160px" })
@Html.TextBoxFor(model => model.Work, new { style = "width:200px" })
</div>
<br/>
<p>
<input type="submit" value="Save" />
</p>
}
</p>
私の編集ビュー
<html>
<body>
@model MVCLayout.Models.Table1
@{
ViewBag.Title = "Edit";
}
<div id="signup">
<div class="rontainer">
<div class="header">
<div id="dock">
<br>
@using (Html.BeginForm("Edit", "AdmServicos", FormMethod.Post, new { @class = "form-inline" }))
{
@Html.AntiForgeryToken()
<fieldset>
<legend>Editar Servios</legend>
<br>
<div class="form-group">
@Html.Label("Código:", new { style = "width:160px" })
@Html.TextBoxFor(model => model.ID, new { style = "width:55px", @readonly = "readonly" })
<div class="form-group">
@Html.Label("Descrição: ", new { style = "width:160px" })
@Html.TextBoxFor(model => model.Descricao, new { style = "width:550px", @readonly = "readonly" })
</div>
</div>
<br />
<br /><br />
<p>
<input type="submit" value="Salvar" />
</p>
</fieldset>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
@{
Html.RenderPartial("CreateTable2", Model.ID);
}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
}
</div>
</div>
</div>
</body>
</html>
は、私は部分ビューまたはこれを行うための最善の方法でこれを行うことができますか?
MVCLayout.Models.Table2モデルをロードしたい場所に何らかのダイアログを追加しようとしていますか?またはMVCLayout.Models.Table1の対応するID? – avi
これを行うことができます。 Model2型のオブジェクトをHtml.RenderPartialまたはHtml.Partialのオーバーロードで渡します。部分図がモーダルで表示されます。 –
@SometimesCode私は、Table2のポストではなく、Table1のポストからモデル化するだけです。コントローラーはどうですか?例をもって私を助けることができますか? – Gustavomacedo