none
Definition for .HasPreviousPage RRS feed

  • Question

  • On my Index.cshtml I'm getting "does not contain definition for 'PageIndex and no extension method for PageIndex."

    Here's the code:

    @page
    @model ContosoUniversity.Pages.Students.IndexModel

    @{
        ViewData["Title"] = "Index";
    }

    <h2>Index</h2>

    <p>
        <a asp-page="Create">Create New</a>
    </p>

    <form asp-page="./Index" method="get">
        <div class="form-actions no-color">
            <p>
                Find by name: <input type="text" name="SearchString" value="@Model.CurrentFilter" />
                <input type="submit" value="Search" class="btn btn-default" /> |
                <a asp-page="./Index">Back to full List</a>
            </p>
        </div>
    </form>

    <table class="table">
        <thead>
            <tr>
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.NameSort"
                       asp-route-currentFilter="@Model.CurrentFilter">
                        @Html.DisplayNameFor(model => model.Student[0].LastName)
                    </a>
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Student[0].FirstMidName)
                </th>
                <th>
                    <a asp-page="./Index" asp-route-sortOrder="@Model.DateSort"
                       asp-route-currentFilter="@Model.CurrentFilter">
                        @Html.DisplayNameFor(model => model.Student[0].EnrollmentDate)
                    </a>
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Student)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.LastName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.FirstMidName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EnrollmentDate)
                    </td>
                    <td>
                        <a asp-page="./Edit" asp-route-id="@item.ID">Edit</a> |
                        <a asp-page="./Details" asp-route-id="@item.ID">Details</a> |
                        <a asp-page="./Delete" asp-route-id="@item.ID">Delete</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>

    @{
        var prevDisabled = !Model.Student.HasPreviousPage ? "disabled" : "";
        var nextDisabled = !Model.Student.HasNextPage ? "disabled" : "";
    }

    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.Student.PageIndex - 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @prevDisabled">
        Previous
    </a>
    <a asp-page="./Index"
       asp-route-sortOrder="@Model.CurrentSort"
       asp-route-pageIndex="@(Model.Student.PageIndex + 1)"
       asp-route-currentFilter="@Model.CurrentFilter"
       class="btn btn-default @nextDisabled">
        Next
    </a>

    Does anyone know how to fix this? Please explain it like I'm a 2 year old.  I'm new to this. Thank you

    • Moved by CoolDadTx Friday, February 9, 2018 3:51 PM ASP.NET related
    Thursday, February 8, 2018 8:00 PM

All replies

  • Hi NonamePI,

    Thank you for posting here.

    For your question is more related to ASP.NET, you could post a new thread in ASP.NET forum for suitable support.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 9, 2018 2:35 AM