Sei sulla pagina 1di 26

Name: Mehul patel

Roll no: 35

Subject:ASP.net

Assignment -3

Q-1 roll no,name,gender,qualification,date of birth submit button display all the data using
querystring,cookies,application.

Querystring:

SOURCE CODE

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

<!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>

<style type="text/css">

.style1

width: 78px;

.style2

width: 347px;

.style3

Page | 14
height: 25px;

.style4

height: 25px;

width: 347px;

</style>

</head>

<body>

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

<table style="height: 288px; width: 488px">

<tr>

<td class="style1" id="l1">

<asp:Label ID="Label1" runat="server" Text="Rollno"></asp:Label>

</td>

<td class="style2">

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

</td>

</tr>

<tr><td>

<asp:Label ID="l2" runat="server" Text="Name"></asp:Label>

</td><td class="style2">

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

</td></tr>

Page | 15
<tr><td class="style3">

<asp:Label ID="l3" runat="server" Text="Gender"></asp:Label>

</td><td id="r2" class="style4">

<asp:RadioButton ID="r1" runat="server" Text="male" GroupName="gender" />

<asp:RadioButton ID="r2" runat="server" Text="female" GroupName="gender" />

</td></tr>

<tr><td>

<asp:Label ID="l4" runat="server" Text="qualification"></asp:Label>

</td><td class="style2">

<asp:CheckBox ID="c1" runat="server" Text="10th" />

<asp:CheckBox ID="c2" runat="server" Text="12th" />

<asp:CheckBox ID="c3" runat="server" Text="graduation" />

<asp:CheckBox ID="c4" runat="server" Text="post graduation" />

</td></tr>

<tr><td>

<asp:Label ID="l5" runat="server" Text="date of birth"></asp:Label>

</td><td class="style2">

<asp:TextBox ID="t4" runat="server" TextMode="Date"></asp:TextBox>

</td></tr>

<tr><td align="center" colspan="2">

<asp:Button ID="b1" runat="server" Text="submit" />

</td></tr>

</table>

</form>

</body>

Page | 16
</html>

Click event

Partial Class v1

Inherits System.Web.UI.Page

Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click

Dim gen As String

If r1.Checked Then

gen = r1.Text

Else

gen = r2.Text

End If

Dim q As String

If c1.Checked Then

q = q + c1.Text

End If

If c2.Checked Then

q = q + " " + c2.Text

End If

If c3.Checked Then

q = q + " " + c3.Text

End If

If c4.Checked Then

q = q + " " + c4.Text

End If

Page | 17
Response.Redirect("v2.aspx?roll=" & t1.Text & "&name=" & t2.Text & "&g=" & gen & "&q=" & q &
"&dob=" & t4.Text)

End Sub

End Class

Second page:

SOURCE CODE

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

<!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>

<style type="text/css">

.style1

width: 321px;

height: 23px;

.style4

height: 22px;

width: 62px;

.style5

width: 62px;

Page | 18
}

.style6

width: 62px;

height: 23px;

</style>

</head>

<body>

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

<div>

<table>

<tr><td class="style6">

<asp:Label ID="l1" runat="server" Text="Roll no"></asp:Label>

</td>

<td class="style1">

<asp:Label ID="l2" runat="server"></asp:Label>

</td></tr>

<tr><td class="style4">

<asp:Label ID="l3" runat="server" Text="name"></asp:Label>

</td><td class="style1">

<asp:Label ID="l4" runat="server"></asp:Label>

</td></tr>

<tr><td class="style5">

<asp:Label ID="l8" runat="server" Text="Gender"></asp:Label>

Page | 19
</td><td>

<asp:Label ID="l5" runat="server"></asp:Label>

</td></tr>

<tr><td class="style5">

<asp:Label ID="Label3" runat="server" Text="qulification"></asp:Label>

</td><td>

<asp:Label ID="l6" runat="server"></asp:Label>

</td></tr>

<tr><td class="style5">

<asp:Label ID="Label5" runat="server" Text="dob"></asp:Label>

</td><td>

<asp:Label ID="l7" runat="server"></asp:Label>

</td></tr>

</table>

</div>

</form>

</body>

</html>

Click event

Partial Class v2

Inherits System.Web.UI.Page

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

l2.Text = Request.QueryString("roll")

l4.Text = Request.QueryString("name")

Page | 20
l5.Text = Request.QueryString("g")

l6.Text = Request.QueryString("q")

l7.Text = Request.QueryString("dob")

End Sub

End Class

Cookie :

SOURCE CODE

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

<!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="height: 288px; width: 488px">

<tr>

<td class="style1" id="l1">

<asp:Label ID="Label1" runat="server" Text="Rollno"></asp:Label>

</td>

<td class="style2">

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

</td>

</tr>

Page | 21
<tr><td>

<asp:Label ID="l2" runat="server" Text="Name"></asp:Label>

</td><td class="style2">

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

</td></tr>

<tr><td class="style3">

<asp:Label ID="l3" runat="server" Text="Gender"></asp:Label>

</td><td id="r2" class="style4">

<asp:RadioButton ID="r1" runat="server" Text="male" GroupName="gender" />

<asp:RadioButton ID="r2" runat="server" Text="female" GroupName="gender" />

</td></tr>

<tr><td>

<asp:Label ID="l4" runat="server" Text="qualification"></asp:Label>

</td><td class="style2">

<asp:CheckBox ID="c1" runat="server" Text="10th" />

<asp:CheckBox ID="c2" runat="server" Text="12th" />

<asp:CheckBox ID="c3" runat="server" Text="graduation" />

<asp:CheckBox ID="c4" runat="server" Text="post graduation" />

</td></tr>

<tr><td>

<asp:Label ID="l5" runat="server" Text="date of birth"></asp:Label>

</td><td class="style2">

<asp:TextBox ID="t4" runat="server" TextMode="Date"></asp:TextBox>

</td></tr>

<tr><td align="center" colspan="2">

Page | 22
<asp:Button ID="b1" runat="server" Text="submit" />

</td></tr>

</table>

</div>

</form>

</body>

</html>

Click event

Partial Class v3

Inherits System.Web.UI.Page

Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click

Dim g As String

If r1.Checked Then

g = r1.Text

Else

g = r2.Text

End If

Dim q As String

If c1.Checked Then

q = q + c1.Text

End If

If c2.Checked Then

q = q + " " + c2.Text

End If

If c3.Checked Then

Page | 23
q = q + " " + c3.Text

End If

If c4.Checked Then

q = q + " " + c4.Text

End If

Response.Cookies("roll").Value = t1.Text

Response.Cookies("name").Value = t2.Text

Response.Cookies("gender").Value = g

Response.Cookies("quli").Value = q

Response.Cookies("dob").Value = t4.Text

Response.Redirect("v4.aspx")

End Sub

Second page:

SOURCE CODE

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

<!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>

<style type="text/css">

.style1

width: 34px;

Page | 24
</style>

</head>

<body>

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

<div>

<table>

<tr><td class="style1">

<asp:Label ID="l1" runat="server" Text="Roll no"></asp:Label>

</td>

<td class="style1">

<asp:Label ID="l2" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td class="style4">

<asp:Label ID="l3" runat="server" Text="name"></asp:Label>

</td><td class="style1">

<asp:Label ID="l4" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="l8" runat="server" Text="Gender"></asp:Label>

</td><td>

<asp:Label ID="l5" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="Label3" runat="server" Text="qulification"></asp:Label>

</td><td>

Page | 25
<asp:Label ID="l6" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="Label5" runat="server" Text="dob"></asp:Label>

</td><td>

<asp:Label ID="l7" runat="server" Text="Label"></asp:Label>

</td></tr>

</table>

</div>

</form>

</body>

</html>

Click event

Partial Class v4

Inherits System.Web.UI.Page

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

l2.Text = Request.Cookies("roll").Value

l4.Text = Request.Cookies("name").Value

l5.Text = Request.Cookies("gender").Value

l6.Text = Request.Cookies("quli").Value

l7.Text = Request.Cookies("dob").Value

End Sub

End Class

Application :

SOURCE CODE

Page | 26
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="v5.aspx.vb" Inherits="v5" %>

<!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>

<style type="text/css">

.style1

height: 46px;

.style2

height: 47px;

.style3

height: 48px;

.style4

height: 50px;

.style5

height: 79px;

Page | 27
}

</style>

</head>

<body>

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

<div>

<table style="height: 288px; width: 488px">

<tr>

<td class="style1" id="l1">

<asp:Label ID="Label1" runat="server" Text="Rollno"></asp:Label>

</td>

<td class="style2">

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

</td>

</tr>

<tr><td>

<asp:Label ID="l2" runat="server" Text="Name"></asp:Label>

</td><td class="style2">

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

</td></tr>

<tr><td class="style3">

<asp:Label ID="l3" runat="server" Text="Gender"></asp:Label>

</td><td id="r2" class="style4">

<asp:RadioButton ID="r1" runat="server" Text="male" GroupName="gender" />

<asp:RadioButton ID="r2" runat="server" Text="female" GroupName="gender" />

Page | 28
</td></tr>

<tr><td class="style5">

<asp:Label ID="l4" runat="server" Text="qualification"></asp:Label>

</td><td class="style5">

<asp:CheckBox ID="c1" runat="server" Text="10th" />

<asp:CheckBox ID="c2" runat="server" Text="12th" />

<asp:CheckBox ID="c3" runat="server" Text="graduation" />

<asp:CheckBox ID="c4" runat="server" Text="post graduation" />

</td></tr>

<tr><td>

<asp:Label ID="l5" runat="server" Text="date of birth"></asp:Label>

</td><td class="style2">

<asp:TextBox ID="t4" runat="server" TextMode="Date"></asp:TextBox>

</td></tr>

<tr><td align="center" colspan="2">

<asp:Button ID="b1" runat="server" Text="submit" />

</td></tr>

</table>

</div>

</form>

</body>

</html>

Page | 29
Click event

Partial Class v5

Inherits System.Web.UI.Page

Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click

Dim g As String

If r1.Checked Then

g = r1.Text

Else

g = r2.Text

End If

Dim q As String

If c1.Checked Then

q = q + c1.Text

End If

If c2.Checked Then

q = q + " " + c2.Text

End If

If c3.Checked Then

q = q + " " + c3.Text

End If

If c4.Checked Then

q = q + " " + c4.Text

End If

Page | 30
Application("roll") = t1.Text

Application("name") = t2.Text

Application("gender") = g

Application("quli") = q

Application("dob") = t4.Text

Response.Redirect("v6.aspx")

End Sub

End Class

Second page:

SOURCE CODE

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

<!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>

<tr><td class="style1">

<asp:Label ID="l1" runat="server" Text="Roll no"></asp:Label>

Page | 31
</td>

<td class="style2">

<asp:Label ID="l2" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td class="style4">

<asp:Label ID="l3" runat="server" Text="name"></asp:Label>

</td><td class="style3">

<asp:Label ID="l4" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="l8" runat="server" Text="Gender"></asp:Label>

</td><td>

<asp:Label ID="l5" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="Label3" runat="server" Text="qulification"></asp:Label>

</td><td>

<asp:Label ID="l6" runat="server" Text="Label"></asp:Label>

</td></tr>

<tr><td>

<asp:Label ID="Label5" runat="server" Text="dob"></asp:Label>

</td><td>

<asp:Label ID="l7" runat="server" Text="Label"></asp:Label>

</td></tr>

</table>

Page | 32
</div>

</form>

</body>

</html>

Click event

Partial Class v6

Inherits System.Web.UI.Page

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

l2.Text = Application("roll").ToString

l4.Text = Application("name").ToString

l5.Text = Application("gender").ToString

l6.Text = Application("quli").ToString

l7.Text = Application("dob").ToString

End Sub

End Class

Page | 33
output

Page | 34
Name: Mehul patel

Roll no: 35

Subject:ASP.net

Q-2 user id ,password button and pass the data using session.

SOURCE CODE

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

<!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>

<style type="text/css">

.style1

height: 24px;

.style2

width: 59px;

.style3

height: 24px;

Page | 35
width: 59px;

</style>

</head>

<body>

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

<div>

<table><tr><td class="style2">

<asp:Label ID="l1" runat="server" Text="user id"></asp:Label>

</td><td>

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

</td></tr>

<tr><td class="style3">

<asp:Label ID="l2" runat="server" Text="password"></asp:Label>

</td><td class="style1">

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

</td></tr>

<tr><td align="center" class="style2" colspan="2">

<asp:Button ID="b1" runat="server" Text="log in" />

</td></tr></table>

</div>

</form>

</body>

</html>

Page | 36
Click event

Partial Class v1

Inherits System.Web.UI.Page

Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click

Session("unm") = t1.Text

Session("pass") = t2.Text

Response.Redirect("v2.aspx")

End Sub

End Class

Second page:

SOURCE CODE

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

<!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>

<style type="text/css">

.style1

height: 23px;

</style>

</head>

<body>

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

Page | 37
<div>

<table><tr><td class="style1">

<asp:Label ID="l1" runat="server" Text="welcome"></asp:Label>

</td><td class="style1">

<asp:Label ID="l3" runat="server"></asp:Label>

</td></tr>

<tr><td align="center" class="style2" colspan="2">

<asp:Button ID="b1" runat="server" Text="log out" />

</td></tr></table>

</div>

</form>

</body>

</html>

Click event

Partial Class v2

Inherits System.Web.UI.Page

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

If (IsNothing(Session("unm"))) Then

Response.Redirect("session.aspx")

End If

l3.Text += Session("unm")

End Sub

Page | 38
Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click

Session.Abandon()

FormsAuthentication.SignOut()

Response.Redirect("v1.aspx")

End Sub

End Class

Output

Page | 39

Potrebbero piacerti anche