I am developing an MVC app in which data is year specific. So, I need to make sure the working year is set before any data is queried. I asked this question before and received the response here. This works just fine to redirect the users to another page. However, this is problematic because the session expiring (I do not want it to be a no expire session). So, if there is inactivity for the session to expire and the user is in the middle of an operation, I do not want the page to be reset because of a redirect to another page to select the year.
After that long introduction (apologies, I wanted to make it clear what I was needing), I ask, is it possible to create a modal dialog if the session is null?
For example:
if (Session["Year"] != null)
{
...
}
else
{
modal dialog to set year and go on our merry way...
}
I looked at examples for jquery UI, but it does not seem to address my particular conundrum.
Thanks for any help.
Yes, here is the jQuery UI component for dialogs. You have to place it in your view though, so you’ll have to pass whatever session value you have to the view so that you can do a logical test there.
http://jqueryui.com/demos/dialog/
UPDATE:
You can create a view that will hold your dialog box. Next you will override the OnActionExecuted Controller action which gets executed on every request. In this action you will do your session check.
Then you will use ViewBag to pass a value to your master/layout view. In that view just do a logical check for the ViewBag value, and show the dialog box appropriately.