Practical 5 - ASP.NET
Page1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="StudentInformation.Page1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Course:</td>
<td>
<asp:DropDownList ID="ddCourse" runat="server">
<asp:ListItem>BCA</asp:ListItem>
<asp:ListItem>MCA</asp:ListItem>
<asp:ListItem>MBA</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Semester:</td>
<td>
<asp:DropDownList ID="ddSemester" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<asp:TextBox ID="txtContactNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 1:</td>
<td>
<asp:TextBox ID="txtSubject1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 2:</td>
<td>
<asp:TextBox ID="txtSubject2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 3:</td>
<td>
<asp:TextBox ID="txtSubject3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Page1.aspx.cs
using System;
namespace StudentInformation
{
public partial class Page1 : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, EventArgs e)
{
Session["name"] = txtName.Text;
Session["course"] = ddCourse.Text;
Session["semester"] = ddSemester.Text;
Session["email"] = txtEmail.Text;
Session["contact"] = txtContactNumber.Text;
Session["subject1"] = txtSubject1.Text;
Session["subject2"] = txtSubject2.Text;
Session["subject3"] = txtSubject3.Text;
Session["percentage"] = (float.Parse(txtSubject1.Text) + float.Parse(txtSubject2.Text) + float.Parse(txtSubject3.Text)) / 3;
Response.Redirect("Page2.aspx");
}
}
}
Page2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page2.aspx.cs" Inherits="StudentInformation.Page2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td class="auto-style1">Name:</td>
<td class="auto-style1">
<asp:Label ID="lblName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Course:</td>
<td>
<asp:Label ID="lblCourse" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">Semester:</td>
<td class="auto-style1">
<asp:Label ID="lblSemester" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:Label ID="lblEmail" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<asp:Label ID="lblContactNumber" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">Marks in Subject 1:</td>
<td class="auto-style1">
<asp:Label ID="lblSubject1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Marks in Subject 2:</td>
<td>
<asp:Label ID="lblSubject2" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Marks in Subject 3:</td>
<td>
<asp:Label ID="lblSubject3" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Percentage Marks:</td>
<td>
<asp:Label ID="lblPercentage" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="StudentInformation.Page1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Course:</td>
<td>
<asp:DropDownList ID="ddCourse" runat="server">
<asp:ListItem>BCA</asp:ListItem>
<asp:ListItem>MCA</asp:ListItem>
<asp:ListItem>MBA</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Semester:</td>
<td>
<asp:DropDownList ID="ddSemester" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<asp:TextBox ID="txtContactNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 1:</td>
<td>
<asp:TextBox ID="txtSubject1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 2:</td>
<td>
<asp:TextBox ID="txtSubject2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Marks in Subject 3:</td>
<td>
<asp:TextBox ID="txtSubject3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Page1.aspx.cs
using System;
namespace StudentInformation
{
public partial class Page1 : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, EventArgs e)
{
Session["name"] = txtName.Text;
Session["course"] = ddCourse.Text;
Session["semester"] = ddSemester.Text;
Session["email"] = txtEmail.Text;
Session["contact"] = txtContactNumber.Text;
Session["subject1"] = txtSubject1.Text;
Session["subject2"] = txtSubject2.Text;
Session["subject3"] = txtSubject3.Text;
Session["percentage"] = (float.Parse(txtSubject1.Text) + float.Parse(txtSubject2.Text) + float.Parse(txtSubject3.Text)) / 3;
Response.Redirect("Page2.aspx");
}
}
}
Page2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page2.aspx.cs" Inherits="StudentInformation.Page2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td class="auto-style1">Name:</td>
<td class="auto-style1">
<asp:Label ID="lblName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Course:</td>
<td>
<asp:Label ID="lblCourse" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">Semester:</td>
<td class="auto-style1">
<asp:Label ID="lblSemester" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:Label ID="lblEmail" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Contact Number:</td>
<td>
<asp:Label ID="lblContactNumber" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style1">Marks in Subject 1:</td>
<td class="auto-style1">
<asp:Label ID="lblSubject1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Marks in Subject 2:</td>
<td>
<asp:Label ID="lblSubject2" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Marks in Subject 3:</td>
<td>
<asp:Label ID="lblSubject3" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Percentage Marks:</td>
<td>
<asp:Label ID="lblPercentage" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Page2.aspx.cs
using System;
namespace StudentInformation
{
public partial class Page2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblName.Text = (string) Session["name"];
lblCourse.Text = (string) Session["course"];
lblSemester.Text = (string) Session["semester"];
lblEmail.Text = (string) Session["email"];
lblContactNumber.Text = (string) Session["contact"];
lblSubject1.Text = (string) Session["subject1"];
lblSubject2.Text = (string)Session["subject2"];
lblSubject3.Text = (string)Session["subject3"];
lblPercentage.Text = ((float) Session["percentage"]).ToString();
}
}
}
Comments
Post a Comment
Post Your Valuable Comments