programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Thursday, July 24, 2014

Example of Session management

Example of Session management:

Session Management or working With Session in , Here we consider an page with C#,In this Example we create a session on button click event and delete session on click event by Programming,
Syntax Of creating Session
Declare Session:
                          Session["mySession"] =null;
 Delete Session:


Code For Aspx page in Programming:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Example of Session</title>
    <form id="form1" runat="server">
    <asp:Label ID="session" runat="server"></asp:Label><br />

    <asp:Button ID="ok" runat="server" Text="Create Session" onclick="ok_Click" />
Create Session

Code of C# in 

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
            Session["mySession"] =null;
            //declear a null Session object name is mySession.
    protected void ok_Click(object sender, EventArgs e)
        //first we ckeck Session........
        if (Session["mySession"] == null)
            Session["mySession"] = "hello your Session is created";
            session.Text = Convert.ToString(Session["mySession"]);
            ok.Text = "delete Session";

            //session is id of Label control and ok is id of Button control.
            if (Session["mySession"] != null)
                session.Text = "";
                ok.Text = "create Session";

Session Created by click on button

Other Post:

Reference :