0

I have 3 steps, each step is its on view. On step 1 I ask for the start date/time(they can pick timezone and time) and store it as UTC, on step 3 I want to show the date/time based on the timezone they selected, without knowing which timezone they selected (don't store it, as users see it based on the computer timezone).

I want to know the best way to do this. I was thinking storing the tempdata, and then re-storing it. Though it doesn't seem like a best practice.

datatest
  • 483
  • 1
  • 5
  • 14

1 Answers1

1

If the model(s) you use for steps 2 and 3 have a Timezone property, you could store the value in a hidden field and have it posted back to you, like this:

Html.HiddenFor(model => model.Timezone);

Alternatives would be putting the value in a cookie (and perhaps then using a CookieValueProvider to get it back) or putting it in session, although the last option isn't really how MVC is 'meant' to be used.

Community
  • 1
  • 1
Steve Wilkes
  • 7,085
  • 3
  • 29
  • 32
  • I like the idea of making a Timezone property for the model for step 2 and the model for step 3. Wouldn't be much different then passing a TempData to another TempData, but its a bit cleaner – datatest Jan 17 '13 at 23:45
  • Yeah, `Timezone` sounds like a natural part of your model, so it makes sense to me to treat it as such rather than taking the steps necessary to put something in TempData for two Post-Redirect-Gets. – Steve Wilkes Jan 18 '13 at 08:11