GreeneScreen
GreeneScreen

Reputation: 653

c# ASP.NET Persistant Data even with page refresh

I have a asp.net page with c# code behind. I have a first panel where the user selects and enters information, they then click continue and that data is stored in variable. A new panel displays on screen and the select some new data which when they click continue stores that data in that panel and sends all the information to a c# program. The problem I an getting is that when I click continue the first time and the page refreshing showing only the new panel all the data defaults to 0. How can I fix this?

Thanks

Upvotes: 0

Views: 414

Answers (1)

user342706
user342706

Reputation:

HTML is a connectionless protocol. This means there is no state. There are ways to mimic state with .net, but html has no means of this by default. If you are using webforms, you can utilize viewstate as long as you are posting back to the same page each time. If you are using mvc, you will either have to submit your data via ajax or you will have to send all the initial data you sent to the server back to the view so when you press continue you can populate it all again. Or just use jQuery/javascript to hide(), show() portions of your page, but wait till everything is completed prior to posting to the server.

Good luck

Upvotes: 1

Related Questions