-1

I'm new to ASP.NET. I'm designing a user interface in Asp.NET and C# where the user can login and then launch an application. When using this application the user has to fill out a form that is 10 pages long.

So, I have used navigation menu and designed the interface in such a way where every page is different menu item and it is a static menu. The user fills out the details on the first page of the form and saves it and the data gets saved in the database.

The problem is he moves to the other page by clicking the menu tab; when he comes back to the first page by using the menu tab for that page all the filled in data is gone and he sees a blank page. I know that is how it works but I want it in such a way that in one sitting when he is filling out the data on the second page (after filling the data on first page) on reverting back to the first page he should be able to see the data that he had filled out.

What concept can I use? I'm not sure view state will be helpful in this scenario.

halfer
  • 19,824
  • 17
  • 99
  • 186
user613037
  • 75
  • 3
  • 10
  • I've tidied up this old question, including removing a request for urgency (we ask people not to do that here, and remind them that readers are mostly volunteers, who will answer at their leisure). Did you reply to any of your helpers below? Please consider voting and/or accepting them; doing so awards the helper a few points, which in turn will encourage them to help again. – halfer Nov 12 '15 at 18:36

5 Answers5

2

You should look into using the Session State variable for storing his information over the entire session. If the user is logged in you should think about storing his information that he enters in a database and having a Boolean state of "ApplicationFinished" to check if he has finished it or not. Otherwise I would have a call on each page to retrieve information from the database that has already been added, so that he can fill out information at different sittings or all at once.

http://msdn.microsoft.com/en-us/library/ms178581.aspx

Session State may be too long term for you, and if that is the case do some research on ViewState. There are a lot of different ways to tackle a problem like this. It all depends on which technology will fit your needs the best.

http://msdn.microsoft.com/en-us/library/ms972976.aspx

Also, if you're using a tab system think about using the AJAX tabs so that the data will remain on the forms even while tabbing through the different tabs.

http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/

Tyler Ferraro
  • 3,753
  • 1
  • 21
  • 28
0

Well, if you are write the data on database, i guess the best (fast) workaround is to add a column named "completed" to the table the hold this informations. If the flag "completed" is not setted to 1, you load the database information and fills the page controls.

When you create a new record in the database, get the ID of the record and set it on Session. If the user gets back to the first page (previous page), you can recover the information ID and load the data.

marcoaoteixeira
  • 505
  • 2
  • 14
0

As long as you are learning new things... add jquery to the list and leverage the JQuery Wizard Plug In. It will allow you to integrate your "10 page form" into a single unit, which can then be sub divided, routed and managed more easily. You can leverage AJAX to save each step, while offering built in navigation and validation methods.

Cos Callis
  • 5,051
  • 3
  • 30
  • 57
0

I would suggest that you switch to using client-side javascript to control your tabs. That way your form data stays in the fields when you switch back and forth between tabs. You can use javascript buttons to guide the user from tab to tab.

I've done this using JQuery. I actually had 150 fields that needed to be captured (they were all required). I group like data on different tabs and then had buttons ('< Previous', 'Next >') which would activate different tabs.

When they are done, then display the 'Save' button.

Kristofer Hoch
  • 246
  • 1
  • 7
0

This not be what you are looking for, but if your problem is that you want all of the input of a previously filled page to show up when a user navigates back to it, and you have already saved all that information, then you can try something like this:

HTML

<input type="text" id="yourID" name = "yourName" value = "<%=data%>"/>

Then all you need to do is set data to public in the code behind. Then to get the value for data just make a call to your database.

Make sure that you make data empty on the init call public string data = ""; or whatever type it is. This way if there is no info, then it will be blank, and if there is saved info, then it will be filled in.

You can also attempt to pass all the data through params in the url like so:

C#

Response.Redirect("webpage.aspx?data=" + data + "&data1=" + data1);

Or though javascript:

window.location = ("webpage.aspx?data=" + data + "&data1=" + data1);

To get the request do this:

if (Request.Params.AllKeys.Contains("data"))
{
   data = Request.Params["data"];    
}

This way is less ideal though if there is a lot of data being passed.

Community
  • 1
  • 1
Soatl
  • 10,224
  • 28
  • 95
  • 153