Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8852261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:21:18+00:00 2026-06-14T13:21:18+00:00

I am new to asp and have written a project that will connect to

  • 0

I am new to asp and have written a project that will connect to a database, retrieve number records and then present those records to the user in a paginated table. The user can then click on a record to edit, make the edit, save the change and be returned to the original table view. The update page is strongly typed.

I am struggling to keep track of which pagination page was last viewed and then navigating back to it. I.e. if the user is on page 5 of 10, they then update a record in from page 5, when the edit is saved the table is shown again but it has gone back to page 1. What is the best method to keep track of the last pagination page?

Any help appreciated.

Chris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:21:19+00:00Added an answer on June 14, 2026 at 1:21 pm

    In the end I used a session cookie on the server to keep track of the pages shown and last search. This meant I could navigate between pages/controller and keep track of which page was showing in each and didn’t need to pass lots of parameters around. I added a new class:

    public class SearchModel 
    {
        public string TargetController { get; set; }
        public string TargetMethod { get; set; }
        public string OriginalSearchCriteria { get; set; }
        public string NewSearchCriteria { get; set; }
        public int Page { get; set; }
    
        public void SetCriteria(String newCriteria, int pageIn)
        {
    
            if (!newCriteria.Equals(OriginalSearchCriteria))
            {
                OriginalSearchCriteria = newCriteria;
                Page = 1;
            }
            else
            {
                Page = pageIn;
            }
        }
    
        public void SetPage(int newPage)
        {
            if (newPage != 0)
                Page = newPage;
    
        }
    
    
    }
    

    In the controller I just added:

    private SearchModel GetSearch()
        {
           SearchModel search = (SearchModel)Session["CgRefCodeSearch"];
           if (search == null)
           {
              search = new SearchModel();
              search.Page = 1;
              search.OriginalSearchCriteria = "";
              Session["CgRefCodeSearch"] = search;
            }
            return search;
         }
    

    On each function in the controller I could then reference this:

    GetSearch().SetPage(page);
    CurrentPage = GetSearch().Page etc...
    

    This was based on stuff I read in this Pro ASP.NET MVC 3 Framework, Third Edition by Adam Freeman; Steven Sanderson. Its really simple but works OK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple jQuery dialog box that will appear in an asp
I have a new asp.net mvc project and i am trying to figure out
I have created the following project structure for my new asp.net mvc project any
I am new to asp.net mvc and i have problems that i think i
I have written an ASP.NET HttpModule and I have a static helper class that
For a user object in my asp.net mvc project, I have written a custom
I have written an ASP.NET web page with C# behind that runs an existing
I have seen mvccontrolstoolkit new upcoming controls for ASP.MVC. In the project description it
I have written a project by ASP.NET and C# which uses dataset for connecting
I have written an ASP.NET MVC application that allows the user to specify their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.