ARB
ARB

Reputation: 295

store data in asp.net pages (Not Sessions)

I am creating 4 asp.net pages. first three pages have 'CONTINUE' button and last page has 'SUBMIT' button. I am not allowed to use Sessions to store first three pages data. and i need to use 'BACK' button on last three pages. when i click 'BACK' button i need to maintain the previous page data entered by user.

As my pages do some postbacks, i cannot use javascript.history function.

My restrictions are:

As the application is served from a web farm, a session object cannot be used. However, for the purpose of this excersise, consider session object as database-like persistent space where you can store your data. your code should show an easy way to switch to a different persistent space.

What is databse like persistent space and how to write a code to switch to different persistent space?...

Please give me some idea on how to proceed....

Thank you

Upvotes: 0

Views: 926

Answers (4)

graham mendick
graham mendick

Reputation: 1839

I've written a Navigation project for Web Forms you'll find interesting because it takes a new approach to remembering the pages visited and data entered, http://navigation.codeplex.com/

I've also written an introductory article about it in last month's MSDN Magazine, http://msdn.microsoft.com/en-gb/magazine/hh975349.aspx

If you're interested or need any help, let me know

Upvotes: 0

Vasile Laur
Vasile Laur

Reputation: 695

Have you considered storing data in database via some web service calls or something? Why not just make an Ajax call to store and retrieve data every time you navigate to the new page?

   $(document).ready(function () {
    $.ajax({
              type: "POST",
              url: "/Services/SomeServiceService.asmx/GetData",
              data: "{ 'myval' : 'someval'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              error: function (resp) { alert("ERROR\n" + resp.responseText); },
              success: function (data) {
             }
    });
    $(".next").click(function(event){
      $.ajax({
               type: "POST",
               url: "/Services/SomeServiceService.asmx/SaveData",
               data: "{ 'myval' : 'someval'}",
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               error: function (resp) { alert("ERROR\n" + resp.responseText); },
               success: function (data) {
              }
     });
    });
  });

Upvotes: 0

Gerasimos R
Gerasimos R

Reputation: 2066

I can suggest two solutions. The first one uses database persistent storage for the session, since this solves the web farm anti-requirement. It is easy to do that and requires zero code, only configuration (and of course the database). The only (trivial in 99% of cases) caveat is that anything you store in session must be [Serializable]. This renders the web farm issue irrelevant, as all nodes will share the same database, which makes the problem moot. Check here: http://msdn.microsoft.com/en-us/library/ms972429.aspx

The second one is quite custom, using a number of hidden fields or other controls to store the information (essentially using the Viewstate to transport data) and cross-post between the pages (

Upvotes: 0

Devjosh
Devjosh

Reputation: 6496

ASP.Net Wizard Control can be an option in your case. because all Next and Previous navigation are managed by the control itself and there are Events Defined For each Next Previous and Finish Buttons. The controls State will automatically be stored in Viewstate and Managed by the Wizard control itself you don't need to repopulate the controls again and again.

You can find more detail here on MSDN article or see an Example Here

Upvotes: 2

Related Questions