i’m using asp.net and c#.
I have some variable like CurrentCulture, SignedinUserEmail, MenuItemID for for each page that are used in different method and events, which way is the best for holding their values?
private string _CurrentCulture;
private string CurrentCulture
{
get
{
return _CurrentCulture;
}
set
{
_CurrentCulture = value;
}
}
or
private string CurrentCulture
{
get
{
if (ViewState["CurrentCulture"] == null)
{
return "en-UK";
}
else
{
return ((string)ViewState["CurrentCulture"]);
}
}
set
{
ViewState["CurrentCulture"] = value;
}
}
their values might assign by query string or another local variable.
We can best use each one as:
The
CurrentCulture,SignedinUserEmailis better to saved on session because you want to use it on every call, on every page view, with and with out post back.