Header Ads Widget

Practical-12 || ASP.NET || Develop a web page to implement the concept of state management using Session and Application

 

Practical-12

 _ASP.NET


Practical-12: Develop a web page to implement the concept of state management using

 Session and Application 


Home.aspx:-

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Home.aspx.vb"

Inherits="Practical12ApplicationSession.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 id="Head1" runat="server">

 <title></title>

</head>

<body>

 <form id="form1" runat="server">

 <div>

 

 </div>

 </form>

</body>

</html> 

 

 

Login.aspx:-

<%@ Page Language="vb" AutoEventWireup="false"

CodeBehind="Login.aspx.vb"

Inherits="Practical12ApplicationSession.Login" %>

<!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 id="Head1" runat="server">

 <title></title>

</head>

<body>

 <form id="form1" runat="server">

 <div>

 

 <table style="width:100%;">

 <tr>

 <td>

 User Id</td>

 <td>

 <asp:TextBox ID="txtUsername"runat="server"></asp:TextBox>

 </td>

 <td>

  </td>

 </tr>

 <tr>

 <td>

 Passcode</td>

 <td>

 <asp:TextBox ID="txtPassword" runat="server"TextMode="Password"></asp:TextBox>

 </td>

 <td>

  </td>

 </tr>

 <tr>

 <td>

  </td>

 <td>

 <asp:Button ID="btnLogin" runat="server"Text="Login" />

 </td>

 <td>

  </td>

 </tr>

 </table>

 </div>

 </form>

</body>

</html>

 

 

 

Home.aspx.vb:-

Public Class Home

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Response.Write("Welcome : " & Session.Item("username"))

        Response.Write("<br/>Last logged in user : " &

       Application.Item("username"))

    End Sub

End Class

 

Login.aspx.vb:-

Public Class Login

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click

        Session.Item("username") = txtUsername.Text

        Application.Item("username") = txtUsername.Text

        Response.Redirect("Home.aspx")

    End Sub

End Class

 

 

Output Screenshot:-



Second User Log in:-


First user homepage after refreshing:-




















Post a Comment

0 Comments