Юзаем сессии в ASP.NET
Специально для Романа выкладываю кусок кода из одного или *ой … вобщем не важно. Тут пример кода, где я юзаю сессию
Default.aspx.cs
-
using System;
-
using System.Configuration;
-
using System.Data;
-
using System.Linq;
-
using System.Web;
-
using System.Web.Security;
-
using System.Web.UI;
-
using System.Web.UI.HtmlControls;
-
using System.Web.UI.WebControls;
-
using System.Web.UI.WebControls.WebParts;
-
using System.Xml.Linq;
-
-
public partial class _Default
System.Web.UI.Page -
{
-
protected string mode;
-
-
// configuration
-
protected const string _dirCatalog = "/calc/";
-
-
public string Mode
-
{
-
get { return this.mode; }
-
}
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
if (Session["mode"] == null)
-
{
-
Session["mode"] = this.mode = "gen";
-
}
-
if (HttpContext.Current.Request.QueryString["setmode"] != null)
-
{
-
Session["mode"] = this.mode = HttpContext.Current.Request.QueryString["setmode"];
-
//HttpContext.Current.Response.Redirect(_dirCatalog);
-
}
-
-
}
-
-
protected void ChangeMode(object sender, EventArgs e)
-
{
-
if (Session["mode"] == null)
-
{
-
Session["mode"] = "gen";
-
}
-
else
-
{
-
if (Session["mode"].ToString() == "gen")
-
{
-
Session["mode"] = "eng";
-
}
-
else
-
{
-
Session["mode"] = "gen";
-
}
-
}
-
this.mode = Session["mode"].ToString();
-
}
-
}
Похожие записи:
Метки: Личное


RSS