我在强类型视图中有一个模型,但我希望有一个选择按钮,为每个项目调出一个模态,问题是我如何在模态定义中使用razor,因此每个模态都被称为myModal1, myModal2等各自为客户名称:
<a class="btn" data-toggle="modal" href="#myModal">Select</a>
<div class="modal hide" id="myModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Customer Options</h3>
</div>
<div class="modal-body">
<p>
@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}) |
@Html.ActionLink("Details", "Details", New With {.id = currentItem.CustomerId})
|
@Html.ActionLink("Delete", "Delete", New With {.id = currentItem.CustomerId}) |
@Html.ActionLink("Book Job", "Create", "Job", New With {.id = currentItem.CustomerId}, Nothing)
|
@Html.ActionLink("Jobs", "ShowCustomerJobs", "Job", New With {.id = currentItem.CustomerId}, Nothing)
|
@Html.ActionLink("Bills", "BillsForCustomer", "Bill", New With {.id = currentItem.CustomerId}, Nothing)
|
@Html.ActionLink("Send Message", "SendCustomerMessage", "SendMessage", New With {.id = currentItem.CustomerId}, Nothing)
|
@Html.ActionLink("Record Payment", "RecordPayment", "Payment", New With {.id = currentItem.CustomerId}, Nothing)
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
基本上是这样的(这不起作用):
<a class="btn" data-toggle="modal" href="#myModal@currentItem.CustomerId">Select</a>
<div class="modal hide" id="myModal@currentItem.CustomerId">
我不确定Razor在id和href定义中调用Razor的正确定义是什么
答案 0 :(得分:2)
只需添加方括号()@(currentItem.CustomerId)
<a class="btn" data-toggle="modal" href="#myModal@(currentItem.CustomerId)">Select</a>
<div class="modal hide" id="myModal@(currentItem.CustomerId)">