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 6209923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:04:14+00:00 2026-05-24T06:04:14+00:00

I need help because I didn’t find out a solution for a project where

  • 0

I need help because I didn’t find out a solution for a project where I am using MVVM.
In one hand I have a Default.aspx that contains an UpdatePanel with two user controls. The first control is a FilterControl with some Fields to filter.
The second control is a GridView that allows pagination and populates data from the database when I press the button search in my FilterControl. Let’s say that the query returns 100 records. So if I set the PageSize to 20 results I have 5 pages in my GridView ok?

On the other hand I have a Details page with a FormView that recieves an Id parameter of an item from the GridView and shows the information about it. Just above of asp:FormView code I have another user control that gets the data filtered from the gridview in a Session variable throught the corresponding ViewModel, and calculates which items should be next and previous so I have one “Back to List” link and “Previous” and “Next” links. The previous and next links loads correctly. They are LinkButtons with OnClick event that makes Response.Redirect(PrevLink); for example, where PrevLink is the link where the page redirects ~/details.aspx?Id=5).

I am controlling the navigation asynchronously throughout an eventHandler and HistoryEventArgs so when I press the Back button of the browser everything is fine and I get the desired results in default.aspx page. Whenever a postback is fired in default page, when changing the page index of the gridview, for example, or executing a new query in the filter, I call the AddHistoryPoint of ScriptManager and save several keys and values (Filter fields, Number of page, etc).

The problem comes when I press the Back to List LinkButton. I wish the data were the same as before going to the detail page. I have Response.Redirect(“~/default.aspx”) in the OnClick event of this button.

Do you have any ideas in how to manage this?

Thank you very much!!


Copied code from the answer here

Thank you for the answers. @Guvante I don’t want to put the “back to list” on client side because when I Edit the Details page the visible property of the navigation control is set to false. I think I didn’t express myself correctly. But I don’t have the Response.Redirect in the OnClick event of the aspx page. What I have in the source code of the page is OnClick=lkbBackToList_Navigate.

I have it in the codebehind in this way:

protected void lkbNext_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.NextUrl);
}

protected void lkbPrevious_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.PreviousUrl);
}

protected void lkbBackToList_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.BackToListUrl);
}
@msarchet this is some of my code in default.aspx code behind. When I do postback I save the state of the filters, pageindex and so on in session

public event EventHandler<HistoryEventArgs> CaptureClientBrowsing;

protected void Page_OnInit(EventArgs e) 
{
    this.CaptureClientBrowsing += new EventHandler<HistoryEventArgs>(CaptureClientBrowsing_Event); 
}

protected override void SaveDataInSession() 
{
    SaveInSession("FilterViewModel", this.FilteringControl.ViewModel);
    SaveInSession("PageIndex", this.CurrentPageIndex); //CurrentPageIndex is a property with the page index of the gridview 
}

protected void CaptureClientBrowsing_Event(object sender, HistoryEventArgs e) 
{    LoadDataFromSession(e.State); //e.State is a NameValueCollection with the values stored in session for example FilterViewModel has the user control FilteringControl and "PageIndex" has the page index of the gridview    ControlsDataBinding(); 
}

The SaveInSession method just keep Session[key] = object where key is a string as it follows:

string key = string.Format("{0}.{1}.{2}", this.GetType(), nameValue, index); 

an example of key is

"ASP.customers_default_aspx.PageIndex.1"` so `Session[key]=1

If I click in other page (for example the page number 6) of the grid view the value of the key variable would be

"ASP.customers_default_aspx.PageIndex.2"` and `Session[key]=5

Here is where I am stuck. If I browse from the details page to default page clicking back in the browser the CaptureClientBrowsing_Event fires and the controls are loaded correctly and also the values of the filter.

What I want is that when I click the LinkButton “Back to List” the controls and the filter get loaded too. How do I get the NameValueCollection if I don’t have the history args? If I click three times to next and then click to Bak to list how do I know the Session values to load?

Maybe there are a lot of questions and this is hard to handle but I’ve tried to be the most specific I could.

  • 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-05-24T06:04:15+00:00Added an answer on May 24, 2026 at 6:04 am

    You said it’s already working correctly when the user goes from listpage to detailpage then clicks browser Back btn. How is the CaptureClientBrowsing event fired? Can you post code that shows that?

    And couldn’t you reuse the same mechanism when they click Back To List?

    UPDATE:
    Okay, then there is a need to send additional state information back when you Response.Redirect() to the listpage.

    You could use any of the common techniques: pass a querystring parameter, set a cookie, or set another Session variable.

    Detect that signal in the listpage Init or Load, LINQ query the Session keys to get maxHistoryIndex, then restore state from Session using keys derived from maxHistoryIndex.

    E.g. if they clicked to detailpage after having paged through listpage 3 times, maxHistoryIndex=3 and you can restore Session[String.Format("ASP.customers_default_aspx.PageIndex.{0}", maxHistoryIndex)]

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

Sidebar

Related Questions

I need help on regex or preg_match because I am not that experienced yet
I need a regexp help, because for me it will take a lot of
Need help writing a script downloads data from google insight using c# this is
I have found the following post, which I think I may help because I
I have a project where I need to create a desktop app that acts
I need help with binding back after I unbind an element. Basically, I have
Hey guys I need some help with this: I have two view controllers, let's
So I'm doing Project Euler because dear gods do I need to practice writing
I need some help figuring out this for loop logic. I know exactly what
Sorry if I didn't show you the code because I have no idea how

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.