WEBLABC#
WEBLABC#
SEL-310
Lab Journal 8
MOHAMMAD UMER
01-134202-031
BS CS 6B
Objectives:
• To learn about server side scripting
a. forms
b. integration
• To be able to create website on asp.net platform
Tools Used:
Visual Studio
Submission Date:
Evaluation: Signatures of Lab Engineer:
Task # 1:
Create a ASP.NET Web Forms application. Take, as input, the number of rows and number of columns
from the user in that form. After the form is submitted to the server (posted back using “submit”), the
page should be displayed showing a table having the same number of rows and columns as were
input/submitted by the user originally. Populate each cell of the table with the sum of its row number
and column number. For example, cell in row 1 column 1 should display the value 2 as 1+1 = 2
Procedure/Program:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication1._Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Table Generator</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Table Generator</h2>
<asp:Label ID="lblRows" runat="server" Text="Number of Rows:"></asp:Label>
<asp:TextBox ID="txtRows" runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblColumns" runat="server" Text="Number of
Columns:"></asp:Label>
<asp:TextBox ID="txtColumns" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Generate Table"
OnClick="btnSubmit_Click" />
</div>
<br />
<div id="tableContainer" runat="server">
<asp:Table ID="table" runat="server"></asp:Table>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
GenerateTable();
}
}
table.Rows.Clear();
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
tableContainer.Visible = true;
}
}
}
}
Result/Output:
Analysis:
Task # 2:
Complete (all steps of) the ASP.NET web form explained in the class tutorial.
Procedure/Program:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication1.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Employee Information</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Employee Information</h2>
<label for="txtFirstName">First Name:</label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<br />
<label for="txtLastName">Last Name:</label>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
<br />
<label for="ddlGender">Gender:</label>
<asp:DropDownList ID="ddlGender" runat="server">
<asp:ListItem Text="Male" Value="Male"></asp:ListItem>
<asp:ListItem Text="Female" Value="Female"></asp:ListItem>
</asp:DropDownList>
<br />
<label for="ddlDepartment">Department:</label>
<asp:DropDownList ID="ddlDepartment" runat="server">
<asp:ListItem Text="HR" Value="HR"></asp:ListItem>
<asp:ListItem Text="IT" Value="IT"></asp:ListItem>
<asp:ListItem Text="Finance" Value="Finance"></asp:ListItem>
<asp:ListItem Text="Marketing" Value="Marketing"></asp:ListItem>
</asp:DropDownList>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClick="btnSubmit_Click" />
<br />
<asp:Label ID="lblResult" runat="server" Visible="false"></asp:Label>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
lblResult.Text = message;
lblResult.Visible = true; // Show the result label
}
}
}
Result/Output:
Analysis: