44
IS Theory and Practice LAB RECORD-INFS -260/L kishore Thekkepushpakam Nambeesan Student ID No: 25012245 LECTURER-IN - CHARGE Mr. Kishore Nambeesan Information Systems Department University of Nizwa, Sultanate of Oman

جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

IS Theory and Practice

LAB RECORD-INFS -260/L

kishore Thekkepushpakam Nambeesan

Student ID No: 25012245

LECTURER-IN - CHARGE

Mr. Kishore Nambeesan

Information Systems Department

University of Nizwa, Sultanate of Oman

Page 2: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

University of NizwaCollege of Economics Management and Information

Systems

Department of Information Systems

CERITFICATECertified that, this is the Bonafide Practical Record Work

of Mr/Ms. Kishore Nambeesan ID No: 10025421,, Bachelor

of Information Systems Spring-Semester student of

College of Economics Management and Information

Systems in the subject “IS Theory and Practice (INFS-260/L) ” for the

Academic year 2013- 2014.

Dr. Arockiaswamy Mr. Kishore Nam Nambeesan

HOD – IS Department Lecturer –ICB-INFS-280/L

CEMIS CEMIS

Examiners

IS Theory and Practice-INFS-260/L- LAB RECORD Page 1

Page 3: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

1.

2.

Table of Contents

Task. No: Title Page Nos. Date

1) ASP Page showing a Button and Changing Colour On Click 16.09.2014

2) ASP Page showing a Currency Conversion 23.09.2014

3) ASP page for Name Filed and Choice Validation 30.09.2014

4) ASP Page for Customer Web form Validation 14.10.2014

5) ASP Page for Web registration Process with SQL database. 12.11.2014

6) ASP Page for creating Online Phone Book 09.12.2014

7)

8)

9)

IS Theory and Practice-INFS-260/L- LAB RECORD Page 2

Page 4: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

10)

11)

IS Theory and Practice-INFS-260/L- LAB RECORD Page 3

Page 5: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

TASK -1:

ASP Page showing a Button and Changing Its Colour Date: 16/09/14

Objective:

This ASP Page showing a Button which will change its Colour

while clicking on it.

Code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<!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>Welcome to UNIZWA</title></head><body bgcolor="#cc99ff"> <form id="form1" runat="server"> <div> </div> <asp:Button ID="Button1" runat="server" Text="Click me" style="height: 26px" /> </form></body></html>

Script

Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Button1.Style("background-color") = "#0000ff" Button1.Style("color") = "#ffffff" Button1.Style("width") = "200px" Button1.Style("cursor") = "pointer" Button1.Style("font-family") = "verdana" Button1.Style("font-weight") = "bold" Button1.Style("font-size") = "14pt" Button1.Text = "You clicked me!" MsgBox("Thank you!") End SubEnd Class

IS Theory and Practice-INFS-260/L- LAB RECORD Page 4

Page 6: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Output –Screenshots

IS Theory and Practice-INFS-260/L- LAB RECORD Page 5

Page 7: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

TASK -2:

ASP Page showing a Currency Conversion Date: 23/09/14

Objective:

This ASP Page will do the required currency conversion from One Currency to Another.

Code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="ASP_CurrencyConverter._Default" %>

<!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>Untitled Page</title> <style type="text/css"> #Result { font-weight: 700; } .style1 { color: #0000FF; } .style2 { color: #FF0066; } </style></head><body> <form id="form1" runat="server" title="Welcome to Online Currency Converter "> <asp:Label ID="Label1" runat="server" ForeColor="#000099" style="font-weight: 700; text-decoration: underline" Text="Welcome to Online Currency Converter"></asp:Label> <br /> <br /> <b><span class="style2">Convert :</span> <asp:TextBox ID="US" runat="server" Font-Bold="True" ForeColor="Blue" Width="222px"></asp:TextBox>&nbsp; <span class="style1">US Dollars</span> to :&nbsp; <asp:DropDownList ID="Currency" runat="server"> <asp:ListItem Value="0.85">Euros</asp:ListItem> <asp:ListItem Value="110.33">Japanese Yen</asp:ListItem> <asp:ListItem Value="1.2">Canadian Dollars</asp:ListItem> </asp:DropDownList> <br /> <br /> <asp:Button ID="Convert" runat="server" ForeColor="Maroon" style="font-weight: 700; color: #660033;" Text="Click to CONVERT"

IS Theory and Practice-INFS-260/L- LAB RECORD Page 6

Page 8: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

BackColor="Aqua" /> <hr style="color: #800000" /> </b> <div id="Result" style="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align: center; color: #660033;" runat="Server"> </div> </form></body></html>

Script

Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Convert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Convert.Click Dim oldAmount As Double = Val(US.Text) ' Retrieve the selected ListItem object by its index number. Dim item As ListItem = Currency.Items(Currency.SelectedIndex) Dim newAmount As Double = oldAmount * Val(item.Value) Result.InnerText = oldAmount.ToString() & " U.S. dollars = " Result.InnerText &= newAmount.ToString() & " " & item.Text End SubEnd Class

IS Theory and Practice-INFS-260/L- LAB RECORD Page 7

Page 9: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Output –Screenshots

IS Theory and Practice-INFS-260/L- LAB RECORD Page 8

Page 10: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Task-3: ASP page for Name Filed and Choice Validation Date: 30.09.2014

Objective:

This ASP Page will do the validation for the Name Field and the Card Type selection using the RequiredField Validator and Validation Control.

Code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="ASP_FieldValidation_Task3._Default" %>

<!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>Untitled Page</title> <style type="text/css"> .style1 { width: 100%; margin-right: 0px; background-color: #99CCFF; } .style2 { width: 531px; } .style3 { } .style4 { width: 114px; font-weight: bold; color: #000000; } .style5 { width: 114px; font-weight: bold; color: #000000; height: 93px; } .style6 { width: 531px; height: 93px; } .style7 { width: 148px; height: 93px; } .style8 {

IS Theory and Practice-INFS-260/L- LAB RECORD Page 9

Page 11: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

color: #000000; } .style9 { height: 10px; } </style></head><body> <form id="form1" runat="server"> <div style="width: 563px"> <table class="style1"> <tr> <td class="style4"> Name: </td> <td class="style2" colspan="2"> <asp:TextBox ID="txtname" runat="server" BackColor="#FF99CC" BorderColor="#0066FF" Width="198px"></asp:TextBox> <span class="style8"> <asp:RequiredFieldValidator ID="rf1" runat="server" ControlToValidate="txtname" ErrorMessage="Your Name Missing (*)" style="font-weight: 700; font-size: large">*</asp:RequiredFieldValidator> </span> </td> </tr> <tr> <td class="style5"> Card Type:</td> <td class="style7"> <asp:RadioButtonList ID="cardtype" runat="server" style="font-weight: 700; color: #000000; background-color: #99CCFF"> <asp:ListItem>Diners</asp:ListItem> <asp:ListItem>MasterCard</asp:ListItem> <asp:ListItem>Visa</asp:ListItem> </asp:RadioButtonList> </td> <td class="style6"> <asp:RequiredFieldValidator ID="rf2" runat="server" ControlToValidate="cardtype" ErrorMessage="Card Type not Selected (*)" InitialValue="" style="font-weight: 700; font-size: large">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style3"> &nbsp;</td> <td class="style2" colspan="2"> <asp:Button ID="submit" runat="server" style="font-weight: 700; color: #660066; background-color: #66FFFF" Text="Submit" /> </td> </tr>

IS Theory and Practice-INFS-260/L- LAB RECORD Page 10

Page 12: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

<tr> <td class="style9" colspan="3"> <hr style="background-color: #800000" /> </td> </tr> <tr> <td class="style3" colspan="3"> <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You must enter a value in the following fields:" style="font-weight: 700; font-style: italic" /> </td> </tr> </table> </div> </form></body></html>

Output

IS Theory and Practice-INFS-260/L- LAB RECORD Page 11

Page 13: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Task-4: ASP Page for Customer Web form Validation Date: 14.10.2014

Objective:

This ASP Page will do the validation for the Name Field and the Card Type selection using

Different Field Validators and Validation Controls.

Code:

DHTML Code

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="ASP_TASK4_WebformValidation._Default" %>

<!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>Untitled Page</title> <style type="text/css"> .style1 { text-align: center; font-size: x-large; } .style2 { font-size: medium; text-align: right; } .style3 { color: #CC0000; text-decoration: underline; } .style4 { width: 101%; margin-left: 0px; } .style5 { height: 28px; } .style6 { width: 134px; height: 22px; font-weight: bold; font-size: medium; text-align: right; } .style7 { height: 22px;

IS Theory and Practice-INFS-260/L- LAB RECORD Page 12

Page 14: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

text-align: left; } .style8 { width: 134px; font-weight: bold; font-size: medium; text-align: right; } .style9 { width: 188px; } .style10 { height: 22px; width: 188px; font-size: medium; text-align: right; } .style11 { } .style12 { height: 28px; text-align: right; font-size: medium; } .style13 { width: 134px; font-weight: bold; font-size: medium; text-align: right; height: 26px; } .style14 { width: 188px; height: 26px; font-size: medium; text-align: right; } .style15 { height: 26px; text-align: left; font-size: medium; } .style16 { text-align: left; } .style17 { width: 188px; font-size: medium; text-align: right;

IS Theory and Practice-INFS-260/L- LAB RECORD Page 13

Page 15: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

} .style18 { font-size: medium; text-align: left; } </style></head><body bgcolor="#ff99ff"> <form id="form1" runat="server"> <div class="style1" style="font-weight: 700; margin-left: 40px; width: 694px;"> <table class="style4"> <tr> <td colspan="3" style="text-align: center"> <span class="style3">Welcome to Snap Garden</span></td> </tr> <tr> <td class="style8"> User Name:&nbsp;&nbsp;</td> <td class="style9"> <span class="style2"> <asp:TextBox ID="txtname" runat="server" Width="205px"></asp:TextBox> </span> </td> <td class="style18"> <asp:RequiredFieldValidator ID="rfuname" runat="server" ErrorMessage="You must enter a user name." ControlToValidate="txtname"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style8"> Password:&nbsp;&nbsp;&nbsp;</td> <td class="style17"> <asp:TextBox ID="txtpwd" runat="server" Width="205px" TextMode="Password"></asp:TextBox> </td> <td class="style18"> <asp:RequiredFieldValidator ID="rfpwd" runat="server" ErrorMessage="You must enter a password." ControlToValidate="txtpwd"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style13"> Retype Password:&nbsp;&nbsp;&nbsp;</td> <td class="style14"> <asp:TextBox ID="txtrtpwd" runat="server" Width="205px" TextMode="Password"></asp:TextBox> </td> <td class="style15">&nbsp;<asp:CompareValidator ID="cvrtpwd" runat="server" ControlToCompare="txtpwd"

IS Theory and Practice-INFS-260/L- LAB RECORD Page 14

Page 16: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

ControlToValidate="txtrtpwd" ErrorMessage="Your password does not match."></asp:CompareValidator> </td> </tr> <tr> <td class="style8"> Your E-mail ID:&nbsp;</td> <td class="style17"> <asp:TextBox ID="txtemail" runat="server" Width="205px"></asp:TextBox> </td> <td class="style16"> <asp:RegularExpressionValidator ID="revemail" runat="server" ControlToValidate="txtemail" ErrorMessage="This is not a Valid E-mail ID" style="font-size: medium" ValidationExpression="\S+@\S+\.\S+"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style8"> Age:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td class="style17"> <asp:TextBox ID="txtage" runat="server" Width="205px"></asp:TextBox> </td> <td class="style16"> <asp:RangeValidator ID="rvage" runat="server" ControlToValidate="txtage" ErrorMessage="Age must be between 1 and 120" MaximumValue="120" MinimumValue="1" SetFocusOnError="True" style="font-size: medium" Type="Integer"></asp:RangeValidator> </td> </tr> <tr> <td class="style6"> GSM:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td class="style10"> <asp:TextBox ID="txtgsm" runat="server" Width="205px"></asp:TextBox> </td> <td class="style7"> <asp:RegularExpressionValidator ID="revgsm" runat="server" ControlToValidate="txtgsm" ErrorMessage="This is not a Valid GSM No." style="font-size: medium" ValidationExpression="9\d\d\d\d\d\d\d"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style12" colspan="2"> <asp:Button ID="submit" runat="server" style="font-weight: 700; color: #FFFF66; background-color: #000000; text-align: right;" Text="Submit" /> </td> <td class="style5"> <span class="style2"> <asp:Button ID="cancel" runat="server" style="font-weight: 700; color: #FFFF00; background-color: #000000"

IS Theory and Practice-INFS-260/L- LAB RECORD Page 15

Page 17: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Text="Cancel" CausesValidation="False" /> </span> </td> </tr> <tr> <td class="style11" colspan="3"> <span class="style2"> <asp:Label ID="status" runat="server" style="color: #000066; font-size: large; font-style: italic; font-family: 'Comic Sans MS'" Text="status"></asp:Label> </span> </td> </tr> </table> <br /> </div> </form></body></html>Script

Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles submit.Click If Page.IsValid Then status.Text = "This is a valid form." End If End Sub

Protected Sub cancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cancel.Click status.Text = "No attempt was made to validate this form." End SubEnd Class

Output

IS Theory and Practice-INFS-260/L- LAB RECORD Page 16

Page 18: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

IS Theory and Practice-INFS-260/L- LAB RECORD Page 17

Page 19: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Task-4: ASP Page for Web registration Process with SQL database. Date: 12.11.2014

Objective:

This ASP Page will register will register the User Login Details with the SQL database. After the Successful Registration It will display the Login Details registered with DB.

Code:

DHTML Code

Registartion.aspx.<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Registration.aspx.vb" Inherits="ASP_TASK_5_WebLoginwithDB._Default" %>

<!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>Untitled Page</title> <style type="text/css"> .style1 { text-align: center; } .style2 { width: 69%; background-color: #99CCFF; } .style3 { text-align: right; } .style4 { width: 265px; text-align: right; height: 23px; } .style5 { height: 23px; text-align: left; } #Reset1 { width: 65px; text-align: left; font-weight: 700; background-color: #00CC99; } .style6 { text-align: left;

IS Theory and Practice-INFS-260/L- LAB RECORD Page 18

Page 20: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

} .style7 { } .style8 { height: 23px; text-align: left; width: 248px; } .style9 { text-align: left; width: 248px; } #resetbtn { font-weight: 700; color: #000066; width: 102px; background-color: #00FF99; } .style11 { text-align: center; width: 249px; } .style12 { text-align: center; text-decoration: underline; color: #FF0066; } .style13 { text-align: right; height: 26px; } .style14 { text-align: left; width: 248px; height: 26px; } .style15 { text-align: left; height: 26px; } </style></head><body> <form id="form1" runat="server"> <div class="style1" style="font-weight: 700"> <table class="style2"> <tr> <td class="style3"> &nbsp;</td>

IS Theory and Practice-INFS-260/L- LAB RECORD Page 19

Page 21: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

<td class="style12" colspan="2"> Web Login Authentication</td> <td style="text-align: left"> &nbsp;</td> </tr> <tr> <td class="style3"> Username</td> <td class="style7" colspan="2" style="text-align: left"> <asp:TextBox ID="txtuser" runat="server" Width="246px" MaxLength="25"></asp:TextBox> </td> <td style="text-align: left"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtuser" ErrorMessage="User Name Missing"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style4"> E-mail</td> <td class="style8" colspan="2"> <asp:TextBox ID="txtemail" runat="server" Width="246px"></asp:TextBox> </td> <td class="style5"> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtemail" ErrorMessage="Invalid E-mail address" ValidationExpression="\S+@\S+\.\S+"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style3"> Password</td> <td class="style9" colspan="2"> <asp:TextBox ID="txtpswd" runat="server" TextMode="Password" Width="246px"></asp:TextBox> </td> <td class="style6"> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtpswd" ErrorMessage="Password missing"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style13"> Retype Password</td> <td class="style14" colspan="2"> <asp:TextBox ID="txtrtpaswd" runat="server" TextMode="Password" Width="246px"></asp:TextBox> </td> <td class="style15"> <asp:CompareValidator ID="CompareValidator1" runat="server"

IS Theory and Practice-INFS-260/L- LAB RECORD Page 20

Page 22: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

ControlToCompare="txtpswd" ControlToValidate="txtrtpaswd" ErrorMessage="Password Do not Match, Please retype"></asp:CompareValidator> </td> </tr> <tr> <td class="style3"> Select Your Country</td> <td class="style7" colspan="2" style="text-align: left"> <asp:DropDownList ID="drpl" runat="server" style="text-align: left; color: #0000FF; font-weight: 700; font-family: 'Times New Roman', Times, serif; background-color: #FFFFCC" Width="245px"> <asp:ListItem>Select Your Country</asp:ListItem> <asp:ListItem>Oman</asp:ListItem> <asp:ListItem>UAE</asp:ListItem> <asp:ListItem>Qatar</asp:ListItem> <asp:ListItem>Bahrain</asp:ListItem> <asp:ListItem>Kuwait</asp:ListItem> <asp:ListItem>India</asp:ListItem> <asp:ListItem>UK</asp:ListItem> <asp:ListItem>USA</asp:ListItem> <asp:ListItem>France</asp:ListItem> <asp:ListItem>Germany</asp:ListItem> <asp:ListItem>Italy</asp:ListItem> <asp:ListItem>Turkey</asp:ListItem> <asp:ListItem></asp:ListItem> </asp:DropDownList> </td> <td style="text-align: left"> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="drpl" ErrorMessage="Country not Selected"></asp:RequiredFieldValidator> </td> </tr> <tr> <td class="style3" colspan="2"> &nbsp;</td> <td class="style11"> <asp:Button ID="Registerbtn" runat="server" style="font-weight: 700; color: #000066; background-color: #FF99FF" Text="Register" Width="112px" />&nbsp;<asp:Button ID="Reset" runat="server" style="font-weight: 700; color: #000099; background-color: #00FF99" Text="Reset" Width="112px" />&nbsp;</td> <td class="style3"> &nbsp;</td> </tr> <tr> <td class="style3" colspan="2"> &nbsp;</td> <td class="style11"> <asp:Label ID="lblstatus" runat="server"

IS Theory and Practice-INFS-260/L- LAB RECORD Page 21

Page 23: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

style="color: #0000FF; font-size: large; font-family: Andalus; font-style: italic; background-color: #00FF00;"></asp:Label> </td> </tr> </table> </div> </form></body></html>

Registartion.aspx.vb (VB Script)Imports System.Data.SqlClientImports System.ConfigurationPartial Public Class _Default Inherits System.Web.UI.Page

Protected Sub Registerbtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Registerbtn.Click Dim connectionString As String Dim connection As SqlConnection Dim chkuser As String Dim temp As Integer connectionString = ConfigurationManager.ConnectionStrings("RegistartionConnectionString").ToString connection = New SqlConnection(connectionString) connection.Open() chkuser = "Select count (*)from UserData where UserName='" + txtuser.Text + "'" Dim Com As New System.Data.SqlClient.SqlCommand(chkuser, connection) temp = Convert.ToInt32(Com.ExecuteScalar().ToString) If temp >= 1 Then 'Response.Write("UserName Already exists")

lblstatus.Text = "UserName: " + txtuser.Text + " Already exists" txtuser.Text = ""

txtemail.Text = "" txtpswd.Text = "" txtrtpaswd.Text = "" drpl.SelectedIndex = 0 connection.Close() Else Try Dim conString As String Dim Conn As SqlConnection Dim InsertQuery As String Session("userName") = txtuser.Text conString = ConfigurationManager.ConnectionStrings("RegistartionConnectionString").ToString Conn = New SqlConnection(conString) Conn.Open() InsertQuery = "Insert into UserData (UserName, email, password,country) values (@Uname,@Email,@Password,@Country)" Dim Comd As New System.Data.SqlClient.SqlCommand(InsertQuery, Conn)

IS Theory and Practice-INFS-260/L- LAB RECORD Page 22

Page 24: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Comd.Parameters.AddWithValue("@Uname", txtuser.Text) Comd.Parameters.AddWithValue("@Email", txtemail.Text) Comd.Parameters.AddWithValue("@Password", txtrtpaswd.Text) Comd.Parameters.AddWithValue("@Country", drpl.SelectedItem.ToString) Comd.ExecuteNonQuery() Response.Redirect("Manager.aspx") Conn.Close() Catch ex As Exception Response.Write("Error:" + ex.ToString) End Try End If End Sub

Protected Sub Reset_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Reset.Click txtuser.Text = "" txtemail.Text = "" txtpswd.Text = "" txtrtpaswd.Text = "" drpl.SelectedIndex = 0 End SubEnd Class

Manager.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Manager.aspx.vb" Inherits="ASP_TASK_5_WebLoginwithDB.Manager" %>

<!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>Untitled Page</title> <style type="text/css"> .style1 { font-weight: bold; color: #660033; height: 444px; direction: ltr; } .style2 { color: #10A30C; } .style3 { color: #FF3399; } </style></head><body> <form id="form1" runat="server"> <div class="style1">

IS Theory and Practice-INFS-260/L- LAB RECORD Page 23

Page 25: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

<span class="style3">Welcome.....</span> <asp:Label ID="lbluser" runat="server" style="color: #3333FF; font-size: large; font-family: Andalus; font-style: italic" Text="UserName"></asp:Label> <br /> <span class="style2"><% Response.Write("Your Login details are successfully Registered.")%></span> <br /> Admin Page- User Login Details:<br /> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSourceRegistration" GridLines="Vertical" Width="891px" Height="488px"> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" /> <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" /> <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" /> <asp:BoundField DataField="password" HeaderText="password" SortExpression="password" /> <asp:BoundField DataField="country" HeaderText="country" SortExpression="country" /> </Columns> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="#DCDCDC" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSourceRegistration" runat="server" ConnectionString="<%$ ConnectionStrings:RegistartionConnectionString %>" SelectCommand="SELECT * FROM [UserData]"></asp:SqlDataSource><br /> </div> </form></body></html>

Manager.aspx.vb

Public Partial Class Manager Inherits System.Web.UI.Page

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

IS Theory and Practice-INFS-260/L- LAB RECORD Page 24

Page 26: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Dim userName As String = Session("userName") lbluser.Text = userName + " !" End SubEnd Class

Output

IS Theory and Practice-INFS-260/L- LAB RECORD Page 25

Page 27: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

IS Theory and Practice-INFS-260/L- LAB RECORD Page 26

Page 28: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Task-4: ASP Page for creating Online Phone Book with MS Access database. Date: 09.12.2014

Objective:

This ASP Page will register Phone book details such as First Name, Last, Name, Mobile No, Landline No, E-mail with MS Access DB.

Code:

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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>PhoneBook</title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .style1 { color: #FF0066; } </style></head><body> <form id="form1" runat="server"> <div> &nbsp;<asp:Label ID="Label6" runat="server" CssClass="title">UNIZWA Online PhoneBook</asp:Label><br /> <asp:Label ID="Label7" runat="server" CssClass="subtitle">A Phone Book Web Application for using ASP.Net</asp:Label><br /> <hr /> <br /> <asp:GridView ID="grvContacts" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="ID" GridLines="Vertical" OnRowEditing="RowEditing" OnRowDeleting="RowDeleting" OnPageIndexChanging="PageIndexChanging" Width="919px" EmptyDataText="No PhoneBook records found. "> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <Columns> <asp:BoundField DataField="FirstName" HeaderText="First Name" /> <asp:BoundField DataField="LastName" HeaderText="Last Name" /> <asp:BoundField DataField="Mobile" HeaderText="Mobile" /> <asp:BoundField DataField="Landline" HeaderText="Landline" /> <asp:BoundField DataField="Email" HeaderText="Email" /> </Columns> <RowStyle BackColor="#EEEEEE" ForeColor="Black" />

IS Theory and Practice-INFS-260/L- LAB RECORD Page 27

Page 29: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="Gainsboro" /> </asp:GridView> <br /> <asp:LinkButton ID="lnkAdd" runat="server">Add New Contact</asp:LinkButton><br /> <br /> <br /> <asp:Panel ID="pnlContactsEntry" runat="server" Width="503px"> <table border="0" cellpadding="0" cellspacing="0" style="width: 132%"> <tr> <td style="width: 64px"> <asp:Label ID="Label1" runat="server" Text="First Name"></asp:Label></td> <td style="width: 166px"> <asp:TextBox ID="txtFirstName" runat="server" Width="400px" MaxLength="50"></asp:TextBox></td> <td style="width: 86px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName" ErrorMessage="*required field"></asp:RequiredFieldValidator></td> </tr> <tr> <td style="width: 64px"> <asp:Label ID="Label2" runat="server" Text="Last Name"></asp:Label></td> <td style="width: 166px"> <asp:TextBox ID="txtLastName" runat="server" Width="400px" MaxLength="50"></asp:TextBox></td> <td style="width: 86px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtLastName" ErrorMessage="*required field"></asp:RequiredFieldValidator></td> </tr> <tr> <td style="width: 64px"> <asp:Label ID="Label3" runat="server" Text="Mobile"></asp:Label></td> <td style="width: 166px"> <asp:TextBox ID="txtMobile" runat="server" Width="400px" MaxLength="15"></asp:TextBox></td> <td style="width: 86px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtMobile" ErrorMessage="*required field"></asp:RequiredFieldValidator></td> </tr> <tr> <td style="width: 64px; height: 19px"> <asp:Label ID="Label4" runat="server" Text="Landline"></asp:Label></td>

IS Theory and Practice-INFS-260/L- LAB RECORD Page 28

Page 30: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

<td style="width: 166px; height: 19px"> <asp:TextBox ID="txtLandline" runat="server" Width="400px" MaxLength="10"></asp:TextBox></td> <td style="width: 86px; height: 19px"> </td> </tr> <tr> <td style="width: 64px"> <asp:Label ID="Label5" runat="server" Text="Email"></asp:Label></td> <td style="width: 166px"> <asp:TextBox ID="txtEmail" runat="server" Width="400px" MaxLength="50"></asp:TextBox></td> <td style="width: 86px"> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail" ErrorMessage="*invalid format" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td> </tr> <tr> <td style="width: 64px"> </td> <td colspan="2"> <asp:LinkButton ID="lnkSave" runat="server">Save</asp:LinkButton> <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False">Cancel</asp:LinkButton></td> </tr> </table> </asp:Panel> <asp:Label ID="lblMessage" runat="server" CssClass="label_message"></asp:Label><br /> <br /> <br /> <br /> <br /> <br /> <hr /> &nbsp;Web Application Developed by: <span class="style1">IS Theory and Practice LAB Students</span></div> </form></body></html>Contacts.vb

Imports Microsoft.VisualBasicImports System.DataImports System.Data.OleDbImports System.Web.Configuration

Public Class Contacts Private _id As Integer Private _firstname As String Private _lastname As String Private _mobile As String Private _landline As String Private _email As String

IS Theory and Practice-INFS-260/L- LAB RECORD Page 29

Page 31: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Public Property ID() As Integer Get Return _id End Get Set(ByVal value As Integer) _id = value End Set End Property

Public Property FirstName() As String Get Return _firstname End Get Set(ByVal value As String) _firstname = value End Set End Property

Public Property LastName() As String Get Return _lastname End Get Set(ByVal value As String) _lastname = value End Set End Property

Public Property Mobile() As String Get Return _mobile End Get Set(ByVal value As String) _mobile = value End Set End Property

Public Property Landline() As String Get Return _landline End Get Set(ByVal value As String) _landline = value End Set End Property

Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property

Public ReadOnly Property ConnectionString() As String Get Return WebConfigurationManager.AppSettings("connectionString") End Get

IS Theory and Practice-INFS-260/L- LAB RECORD Page 30

Page 32: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

End Property

Public Function Add() As Integer Dim connection As OleDbConnection = New OleDbConnection(Me.ConnectionString)

Dim sql As String = "INSERT INTO Contacts (FirstName, LastName, Mobile, Landline, Email) VALUES ('" sql += FirstName + "','" + LastName + "','" + Mobile + "','" + Landline + "','" + Email + "')"

Dim command As OleDbCommand = New OleDbCommand(sql, connection)

connection.Open() Dim rows_affected As Integer = command.ExecuteNonQuery() connection.Close()

Return rows_affected End Function

Public Function Update() As Integer Dim connection As OleDbConnection = New OleDbConnection(Me.ConnectionString)

Dim sql As String = "UPDATE Contacts SET FirstName='" + FirstName + "', LastName=+'" + LastName + "', Mobile='" + Mobile sql += "', Landline='" + Landline + "', Email='" + Email + "' WHERE ID = " & Me.ID

Dim command As OleDbCommand = New OleDbCommand(sql, connection)

connection.Open() Dim rows_affected As Integer = command.ExecuteNonQuery() connection.Close()

Return rows_affected End Function

Public Function Delete() As Integer Dim connection As OleDbConnection = New OleDbConnection(Me.ConnectionString)

Dim sql As String = "DELETE * FROM Contacts WHERE ID = " & Me.ID

Dim command As OleDbCommand = New OleDbCommand(sql, connection)

connection.Open() Dim rows_affected As Integer = command.ExecuteNonQuery() connection.Close()

Return rows_affected End Function

Public Sub GetContact(ByVal id As Integer) Dim connection As OleDbConnection = New OleDbConnection(Me.ConnectionString)

Dim sql As String = "SELECT * FROM Contacts WHERE ID = " & id

IS Theory and Practice-INFS-260/L- LAB RECORD Page 31

Page 33: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Dim command As OleDbCommand = New OleDbCommand(sql, connection)

Dim dr As OleDbDataReader

connection.Open() dr = command.ExecuteReader()

If dr.Read() Then _id = dr("ID") Me._firstname = dr("FirstName") Me._lastname = dr("LastName") Me._mobile = dr("Mobile") Me._landline = dr("Landline") Me._email = dr("Email") End If

connection.Close() End Sub

Public Function GetContactList() As DataSet Dim connection As OleDbConnection = New OleDbConnection(Me.ConnectionString)

Dim sql As String = "SELECT * FROM Contacts ORDER BY LastName, FirstName"

Dim command As OleDbCommand = New OleDbCommand(sql, connection)

Dim da As OleDbDataAdapter = New OleDbDataAdapter(command)

Dim ds As New DataSet()

da.Fill(ds)

Return ds End FunctionEnd ClassDefault.aspx.vb

Partial Class _Default Inherits System.Web.UI.Page

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

pnlContactsEntry.Visible = False lnkAdd.Visible = True

Dim contacts As New Contacts()

grvContacts.DataSource = contacts.GetContactList grvContacts.DataBind()

End Sub

Protected Sub lnkAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAdd.Click pnlContactsEntry.Visible = True

IS Theory and Practice-INFS-260/L- LAB RECORD Page 32

Page 34: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

lnkAdd.Visible = False

Dim contacts As Contacts = New Contacts()

txtFirstName.Text = "" txtLastName.Text = "" txtMobile.Text = "" txtLandline.Text = "" txtEmail.Text = ""

Session("mode") = "add" End Sub

Protected Sub RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) pnlContactsEntry.Visible = True lnkAdd.Visible = False

Dim contacts As Contacts = New Contacts()

Dim id As Integer = CType(grvContacts.DataKeys(e.NewEditIndex).Value.ToString(), Integer) contacts.GetContact(id)

txtFirstName.Text = contacts.FirstName txtLastName.Text = contacts.LastName txtMobile.Text = contacts.Mobile txtLandline.Text = contacts.Landline txtEmail.Text = contacts.Email

ViewState("id") = id Session("mode") = "edit" End Sub

Protected Sub RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Dim contacts As Contacts = New Contacts() Dim id As Integer = CType(grvContacts.DataKeys(e.RowIndex).Value.ToString(), Integer) contacts.GetContact(id)MsgBox("You are about to delete a Phone contact!!, Proceed?") contacts.Delete() Response.Redirect("Default.aspx") End Sub

Protected Sub lnkSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSave.Click

If Session("mode") <> Nothing Then If Session("mode") = "add" Then Try Dim contacts As Contacts = New Contacts()

contacts.FirstName = txtFirstName.Text contacts.LastName = txtLastName.Text contacts.Mobile = txtMobile.Text contacts.Landline = txtLandline.Text contacts.Email = txtEmail.Text

IS Theory and Practice-INFS-260/L- LAB RECORD Page 33

Page 35: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

contacts.Add() Response.Redirect("Default.aspx") Catch ex As Exception lblMessage.Text = "Error in adding new contact." + Environment.NewLine + ex.Message End Try

Else Try Dim contacts As Contacts = New Contacts() Dim id As Integer = CType(ViewState("id").ToString(), Integer) contacts.GetContact(id)

contacts.FirstName = txtFirstName.Text contacts.LastName = txtLastName.Text contacts.Mobile = txtMobile.Text contacts.Landline = txtLandline.Text contacts.Email = txtEmail.TextMsgBox("Do you want to update this Contact Record?") contacts.Update() Response.Redirect("Default.aspx") Catch ex As Exception lblMessage.Text = "Error in editing contact." + Environment.NewLine + ex.Message End Try

End If End If End Sub

Protected Sub PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) grvContacts.PageIndex = e.NewPageIndex

Dim contacts As New Contacts()

grvContacts.DataSource = contacts.GetContactList grvContacts.DataBind() End SubEnd Class

Web.config

<appSettings><add key="connectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\UNIZWA\FALL-2014-15\ISPT-INFS260-L\ASP-TASKS\ASP-TASK-6-PhoneBook\PhoneBook\App_Data\ContactsDB.mdb"/></appSettings><connectionStrings/>

IS Theory and Practice-INFS-260/L- LAB RECORD Page 34

Page 36: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Output

Adding New PhoneBook Record

IS Theory and Practice-INFS-260/L- LAB RECORD Page 35

Page 37: جامعة نزوى · Web viewstyle="border-style: double; background-color: #99CCFF; font-family: 'Arial Black'; font-size: large; font-weight: 700; font-style: oblique; text-align:

Deleting a PhoneBook Record

Editing/Updating an existing PhoneBook Record

*****THE END*****

IS Theory and Practice-INFS-260/L- LAB RECORD Page 36