@foreach (var item in Model)
{
<div class="col-md-3" style="margin-bottom:20px">
<div class="thumbnail">
<div class="img-responsive" style="margin-bottom:20px">
<img src="~/App_File/images/" height="300" width="240" />
<button type="button" onclick="showDetails(item.value)"></button>
</div>
<div class="caption" style="border-top:3px solid #808080">
<h5 style="font-family:'Comic Sans MS'">Nome: @item.PersonagemNome</h5>
</div>
</div>
</div>
}
In JavaScript you do something like:
function showDetails(item){
alert(item);
}
Remember, each time through the loop, the dynamic
item.value
will be the current one. So there will be numerous buttons. The button will be connected to the
item
value.
First, try it with a String type property of the item then try it with some other property because if that is a complex object then the
showDetails()
function may not get the value you expect.