我有一個局部視圖,它只有它是一個引導模式。
在這個頁面裏叫做lilke這個:ASP MVC - Bootstrap局部視圖問題
@Html.Partial("_PartialEnderecoEditModal", item) |
給我的表的每個項目。
的問題是,當我選擇任何項目,那隻能說明一日一的信息...
我已經檢查了生成的源上的瀏覽器和看起來像這樣:
<tr>
<td style="display:none" id="id">
94
</td>
<td>
rua teste
</td>
<td>
123
</td>
<td>
dhaui'
</td>
<td>
aiujasi
</td>
<td>
sososo
</td>
<td>
sp
</td>
<td>
18000000
</td>
<td>
<style>
#btnEditar {
padding: 0px;
}
</style>
<a class="btn btn-link" id="btnEditar" href="#" role="button" data-toggle="modal" data-target="#ModalEnderecoEdit">Editar</a>
<!-- Modal -->
<div class="modal fade" id="#ModalEnderecoEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cadastro de Endereço</h4>
</div>
<div class="modal-body">
<fieldset id="infoEndereco">
<div class="row">
<div class="col-md-8">
<input class="form-control input-sm text-box single-line" id="een_endereco" name="een_endereco" placeholder="Endereço" type="text" value="rua teste" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_endereco" data-valmsg-replace="true"></span>
</div>
<div class="col-md-4">
<input class="form-control input-sm text-box single-line" id="een_numero" name="een_numero" placeholder="Numero" type="text" value="123" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_numero" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<input class="form-control input-sm text-box single-line" id="een_comple" name="een_comple" placeholder="Complemento" type="text" value="dhaui'" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_comple" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_bairro" name="een_bairro" placeholder="Bairro" type="text" value="aiujasi" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_bairro" data-valmsg-replace="true"></span>
</div>
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_cidade" name="een_cidade" placeholder="Cidade" type="text" value="sososo" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_cidade" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_uf" name="een_uf" placeholder="Estado" type="text" value="sp" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_uf" data-valmsg-replace="true"></span>
</div>
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_cep" name="een_cep" placeholder="CEP" type="text" value="18000000" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_cep" data-valmsg-replace="true"></span>
</div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button id="addEndereco" type="button" OnClick="gravarDetalheEndEdit(this);" class="btn btn-primary">Salvar</button>
</div>
</div>
</div>
</div>
|
<a href="/entidades/Details/94">Details</a> |
<a onclick="excluirUpdateDetalhe(this, 'tabEndereco', 'D');">Excluir</a>
</td>
</tr>
<tr>
<td style="display:none" id="id">
95
</td>
<td>
rua teste2
</td>
<td>
151
</td>
<td>
</td>
<td>
jiojoij
</td>
<td>
joijo
</td>
<td>
ji
</td>
<td>
18000000
</td>
<td>
<style>
#btnEditar {
padding: 0px;
}
</style>
<a class="btn btn-link" id="btnEditar" href="#" role="button" data-toggle="modal" data-target="#ModalEnderecoEdit">Editar</a>
<!-- Modal -->
<div class="modal fade" id="#ModalEnderecoEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cadastro de Endereço</h4>
</div>
<div class="modal-body">
<fieldset id="infoEndereco">
<div class="row">
<div class="col-md-8">
<input class="form-control input-sm text-box single-line" id="een_endereco" name="een_endereco" placeholder="Endereço" type="text" value="rua teste2" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_endereco" data-valmsg-replace="true"></span>
</div>
<div class="col-md-4">
<input class="form-control input-sm text-box single-line" id="een_numero" name="een_numero" placeholder="Numero" type="text" value="151" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_numero" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<input class="form-control input-sm text-box single-line" id="een_comple" name="een_comple" placeholder="Complemento" type="text" value="" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_comple" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_bairro" name="een_bairro" placeholder="Bairro" type="text" value="jiojoij" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_bairro" data-valmsg-replace="true"></span>
</div>
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_cidade" name="een_cidade" placeholder="Cidade" type="text" value="joijo" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_cidade" data-valmsg-replace="true"></span>
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_uf" name="een_uf" placeholder="Estado" type="text" value="ji" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_uf" data-valmsg-replace="true"></span>
</div>
<div class="col-md-6">
<input class="form-control input-sm text-box single-line" id="een_cep" name="een_cep" placeholder="CEP" type="text" value="18000000" />
<span class="field-validation-valid text-danger" data-valmsg-for="een_cep" data-valmsg-replace="true"></span>
</div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button id="addEndereco" type="button" OnClick="gravarDetalheEndEdit(this);" class="btn btn-primary">Salvar</button>
</div>
</div>
</div>
</div>
這是我的部分檢視代碼:
@model prjArqBuild.entidade_endereco
<style>
#btnEditar {
padding: 0px;
}
</style>
<a class="btn btn-link" id="btnEditar" href="#" role="button" data-toggle="modal" data-target="#ModalEnderecoEdit">Editar</a>
<!-- Modal -->
<div class="modal fade" id="#ModalEnderecoEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Cadastro de Endereço</h4>
</div>
<div class="modal-body">
<fieldset id="infoEndereco">
<div class="row">
<div class="col-md-8">
@Html.EditorFor(model => model.een_endereco, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Endereço" } })
@Html.ValidationMessageFor(model => model.een_endereco, "", new { @class = "text-danger" })
</div>
<div class="col-md-4">
@Html.EditorFor(model => model.een_numero, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Numero" } })
@Html.ValidationMessageFor(model => model.een_numero, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
@Html.EditorFor(model => model.een_comple, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Complemento" } })
@Html.ValidationMessageFor(model => model.een_comple, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
@Html.EditorFor(model => model.een_bairro, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Bairro" } })
@Html.ValidationMessageFor(model => model.een_bairro, "", new { @class = "text-danger" })
</div>
<div class="col-md-6">
@Html.EditorFor(model => model.een_cidade, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Cidade" } })
@Html.ValidationMessageFor(model => model.een_cidade, "", new { @class = "text-danger" })
</div>
</div>
<br />
<div class="row">
<div class="col-md-6">
@Html.EditorFor(model => model.een_uf, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "Estado" } })
@Html.ValidationMessageFor(model => model.een_uf, "", new { @class = "text-danger" })
</div>
<div class="col-md-6">
@Html.EditorFor(model => model.een_cep, new { htmlAttributes = new { @class = "form-control input-sm", placeholder = "CEP" } })
@Html.ValidationMessageFor(model => model.een_cep, "", new { @class = "text-danger" })
</div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button id="addEndereco" type="button" OnClick="gravarDetalheEndEdit(this);" class="btn btn-primary">Salvar</button>
</div>
</div>
</div>
</div>
正如您所看到的,它呈現正確。但是當它被稱爲只有第一個彈出。
我認爲這是因爲Modal ID
,但我不確定。
有沒有人有任何想法?
如果你需要更多的細節請問。
@GiorgiNakeuri在頁面呈現的局部視圖的例子 –
呀,'id'可能有問題。我不喜歡在頁面上使用兩個具有相同ID的元素的外觀。你可以用一些能夠唯一標識局部視圖的每個實例的元素後綴嗎?這將是我的第一個猜測。 –
@ stephen.vakil我的主要問題是部分視圖呈現在每個表格行上。這就是我需要的。有沒有辦法改變動態ID或類似的東西? –