I am using bootstrap panel collapse to display a list of messages. When the panel is expanded, the user can see the message in the panel body.
Right now I have hard coded the panel title as "Read Message", but now, the requirement is such that, when the panel is in collapse state, the first line of the message that is there in the panel body should appear as the panel title. I have used a model class from which I am rendering the message body. How can I achieve this?
Here is my code:
View:
@{int i = 0;}
@foreach (var item in Model.MessageHeaderList)
{
<div class="panel-group col-md-8" id="accordion_@i">
<div class="panel panel-default" id="panel_@i">
<div class="panel-heading" id="headingOne_@i">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion_@i" href="#collapseOne_@i">
Read Message
</a>
</h4>
</div>
<div id="collapseOne_@i" class="panel-collapse collapse">
<div class="panel-body">
@Html.Raw(item.MessageText)
</div>
</div>
</div>
</div>
}
i++;