Guest User

Guest User

  • Tech Writer
  • 611
  • 129.3k

Read or Less more in mvc.

Oct 24 2020 5:31 AM
how to implement read more and less functionality for dynamic string inside foreach block in mvc.
@foreach (var item in ViewBag.Texts)
{
<div>
<span class="LongString">@item </span>
<button class="ReadLess">Read Less</button>
</div>
}
public ActionResult ReadMore()
{
List<string> lists = new List<string>() {"abababababa","abababjdvdhg","hfjhdsfqwtw8yqfjref","jegiuigwerhti"};
ViewBag.Texts = lists;
return View();
}

Answers (1)