Guest User

Guest User

  • Tech Writer
  • 611
  • 116.7k

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)