Session tracking:
->Website identifying session belonging to client is called “session tracking”.
->by default session tracking will function using inmemory cookie concept.
->website will provide unique id each session id will be given to client browser in the form of inmemory cookie variable
->browser will submit sessionid to website with each request, based on this sessionid website will identify session belonging is client and session data will be available to client requested webpage
Creating website to work with session concept using theme and skin
Goto visual studio
Start->run->devenv
It will display main window of visual studio
File menu->new->website->visual c#->select asp.net empty website
Weblocation->e:\aspnet\sessionthemesite[drive:\dir\websitename]
Visual studio create a folder with website name, in this folder website related files will be placed
Creating theme into website
->Rightclick on website path-select add asp.net folder-select theme
->provide name as standard
->rightclick on standard theme and select add new item
->select skinfile
Name as skinfile.skin
<%.............
………………%>
<asp:label runat="server" backcolor="red" forecolor="white" font-size="x-large"/>
Creating theme into website
->Rightclick on website path-select add asp.net folder-select theme
->provide name as classic
->rightclick on standard theme and select add new item
->select skinfile
Name as skinfile.skin
<%.............
………………%>
<asp:label runat="server" backcolor="blue" forecolor="white" font-size="x-large"/>
Creating theme into website
->Rightclick on website path-select add asp.net folder-select theme
->provide name as other
->rightclick on standard theme and select add new item
->select skinfile
Name as skinfile.skin
<%.............
………………%>
<asp:label runat="server" backcolor="green" forecolor="aqua" font-size="x-large"/>
Add webform
Goto view menu and select solution explorer
Right click on website path and select add new item
Select webform
Give name as home.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs" Inherits="home" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
goto design part
Standard Classic other |
listbox
Demotext[label1]
Login[hyperlink]
Listbox properties:
Clickon items……add
Standard
Classic
Other
Autopostback-true
Login properties
Navigate url-login.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class home : System.Web.UI.Page
{
protected void Page_preinit(object sender, EventArgs e)
{
// attaching user selected theme to webpage and store with in session
Page.Theme = Request.Form["listBox1"];
Session["stheme"] = Request.Form["listBox1"];
}
}
Add webform
Goto view menu and select solution explorer
Right click on website path and select add new item
Select webform
Give name as login.aspx
goto design part
place label
place hyperlink
label1 properties
text-login info
hyperlink properties
text-register
navigate url-register.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class login : System.Web.UI.Page
{
protected void Page_preinit(object sender, EventArgs e)
{
Page.Theme = Session["stheme"].ToString();
}
}
Add webform
Goto view menu and select solution explorer
Right click on website path and select add new item
Select webform
Give name as register.aspx
goto deign part
place a label with text success fully registerd
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class register : System.Web.UI.Page
{
protected void Page_preinit(object sender, EventArgs e)
{
Page.Theme = Session["stheme"].ToString();
}
}
set home.aspx as start page
[right click on default.aspx and set as start page]
goto contrl F5
Note:
1)page keyword will refer to current asp.net page this can be used to apply settings to asp.net page programmatically
2)theme should be applied to webpage dynamically before controls creation, this requires logic with in preinit event handle