I want to convert this code into VB.NET razor.
<div>
<ul >
@for (var i = 1; i <= Model.TotalPages; i )
{
<li active" : "")">
<a asp-page="/Index" asp-route-currentpage="@i" >@i</a>
</li>
</ul>
</div>
I have tried but doesnt work
@For Each item In Model
@For i = 1 To item.TotalPages
<li Class="page-item @(i == Model.CurrentPage ? "active" : "")">
<a asp-page="/Index" asp-route-currentpage="@i" Class="page-link">@i</a>/li>
i = 1
Next
Next
Can someone please help. Not worked with VB.NET Razor before
CodePudding user response:
I have tried but doesnt work
@For Each item In Model
@For i = 1 To item.TotalPages
<li Class="page-item @(i == Model.CurrentPage ? "active" : "")">
<a asp-page="/Index" asp-route-currentpage="@i" Class="page-link">@i</a>/li>
i = 1
Next
Next
CodePudding user response:
You are trying to use a tag helper to render your anchor. Tag helpers are only available in ASP.NET Core which doesn't provide support for VB.NET in Razor. If you are actually developing a .NET Framework app (MVC 5), you cannot use tag helpers but you can use VB Net:
@For Each item In Model
@For i = 1 To item.TotalPages
<li active", "")">
<a href="/?currentpage=@i" >@i</a>/li>
Next
Next