Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
27 views25 pages

PRIT

The document contains ASP.NET code examples for creating web forms with various functionalities, including a registration form that displays submitted data in a panel, a dynamic panel display based on radio button selection, and a multi-view control to navigate through different views on a single page. Each example includes both the front-end ASPX code and the corresponding backend VB code to handle user interactions. These examples are designed for educational purposes in a TYBCA semester 5 course.

Uploaded by

daveprit3534
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views25 pages

PRIT

The document contains ASP.NET code examples for creating web forms with various functionalities, including a registration form that displays submitted data in a panel, a dynamic panel display based on radio button selection, and a multi-view control to navigate through different views on a single page. Each example includes both the front-end ASPX code and the corresponding backend VB code to handle user interactions. These examples are designed for educational purposes in a TYBCA semester 5 course.

Uploaded by

daveprit3534
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

ASP.

NET TYBCA_SEM-5

1. Create The Registration Form Using Tabular Format And When User
Submit The Form Display Data In A Separate Panel On The Same
Page.
Design :

Code:
Prg1.aspx :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="prg1.aspx.vb"
Inherits="prg1" %>

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

FARHAN IDRISH SHAIKH 1


ASP.NET TYBCA_SEM-5

height: 26px;
}
.style2
{
height: 26px;
width: 629px;
}
.style3
{
width: 629px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td align="center" colspan="2"><h1>Students Information</h1></td>
</tr>
<tr>
<td class="style1">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>

</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="E-mail"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Address"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtaddress" runat="server"
TextMode="MultiLine"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label4" runat="server" Text="Password"></asp:Label></td>
<td class="style3">

2
DAVE PRITA.
ASP.NET TYBCA_SEM-5

<asp:TextBox ID="txtpwd" runat="server"


TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label12" runat="server" Text="Confirm
Password"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtcpwd" runat="server"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Gender"></asp:Label></td> <td
class="style3">
<asp:RadioButtonList ID="radio_gender" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>

</tr>
<tr>
<td style="font-size: small">
<asp:Label ID="Label6" runat="server" Text="Hobby"></asp:Label></td>
<td class="style3">
<asp:CheckBoxList ID="chkbox_hobby" runat="server">
<asp:ListItem>Cricket</asp:ListItem>
<asp:ListItem>Hockey</asp:ListItem>
<asp:ListItem>Football</asp:ListItem>
<asp:ListItem>Volleyball</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>

<tr>
<td colspan="2" align="center">
<asp:Button ID="btnsubmit" runat="server" Text="Submit" ForeColor="Black"
Height="50px" Width="100px" />

<asp:Button ID="btnreset" runat="server" Text="Reset" Height="50px"


Width="100px" /></td>
</tr>
<tr>
<td colspan="2">
<asp:Panel ID="Panel1" runat="server" Visible="False" Height="243px"

3
DAVE PRITA.
ASP.NET TYBCA_SEM-5

Width="955px">
<asp:Label ID="Label7" runat="server"
Text="Name"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblname" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label8" runat="server"
Text="Email"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblemail" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label9" runat="server"
Text="Address"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lbladdress" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label10" runat="server"
Text="Gender"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblgender" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label11" runat="server"
Text="Hobby"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblhobby" runat="server" Text="Label"></asp:Label>

</asp:Panel>
</td>
</tr>
</table>
</div>
</form>
</body> </html>

Prg1.aspx.vb :

Partial Class prg1


Inherits System.Web.UI.Page

Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnsubmit.Click
Panel1.Visible = True
Dim i As Integer
Dim gen As String
For i = 0 To radio_gender.Items.Count - 1
If radio_gender.Items(i).Selected Then
gen = radio_gender.Items(i).ToString
End If
Next

Dim str As String = ""


For i = 0 To chkbox_hobby.Items.Count - 1
If chkbox_hobby.Items(i).Selected Then

4
DAVE PRITA.
ASP.NET TYBCA_SEM-5

str += chkbox_hobby.Items(i).Text + " "


End If
Next
lblname.Text = txtname.Text
lblemail.Text = txtemail.Text
lbladdress.Text = txtaddress.Text
lblgender.Text = gen lblhobby.Text
= str
End Sub
Protected Sub btnreset_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnreset.Click
txtname.Text = "" txtemail.Text
= "" txtaddress.Text = ""
txtpwd.Text = "" txtcpwd.Text
= ""
radio_gender.ClearSelection()
chkbox_hobby.ClearSelection()
End Sub End
Class Output:

5
DAVE PRITA.
ASP.NET TYBCA_SEM-5

2. Create The Webpage Using Panel According To The Following


Criteria. Whatever Radio Button User Is Selecting According To That
Appropriate Panel Should Be Is Played.
Design :

Code:
Prg2.aspx :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="prg2.aspx.vb"
Inherits="prg2" %>

<!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></title>
<style type="text/css">
.style1
{
height: 23px;
width: 118px;
}
.style2
{
width: 118px;
}
.style3

6
DAVE PRITA.
ASP.NET TYBCA_SEM-5

{
width: 629px;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<th class="style1" > Select Stream</th>
<tr>
<td class="style2">Stream</td>

<td class="style3">
<asp:RadioButtonList ID="rdstream" runat="server" AutoPostBack="True">
<asp:ListItem Text="BCA" Value="BCA" />
<asp:ListItem Text="BBA" Value="BBA" />
<asp:ListItem Text="BCOM" Value="BCOM" />
</asp:RadioButtonList>
</td>

</tr>

<tr>
<td colspan="2">

<asp:Panel ID="Panel1" runat="server" Visible="False" Height="92px"


Width="601px">
<h3 align="center">PANEL-1 </h3>
<asp:Label ID="Label10" runat="server" Text="Stream You Have Selected Is
:"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblstream" runat="server" Text="BCA"></asp:Label><br />

</asp:Panel>
</td>
</tr>
<tr>
<td colspan="2">

<asp:Panel ID="Panel2" runat="server" Visible="False" Height="92px"


Width="601px">
<h3 align="center">PANEL-2 </h3>
<asp:Label ID="Label1" runat="server" Text="Stream You Have Selected Is
:"></asp:Label>&nbsp;&nbsp;&nbsp;

7
DAVE PRITA.
ASP.NET TYBCA_SEM-5

<asp:Label ID="Label2" runat="server" Text="BBA"></asp:Label><br />

</asp:Panel>
</td>
</tr>
<tr>
<td colspan="2">

<asp:Panel ID="Panel3" runat="server" Visible="False" Height="92px"


Width="601px">
<h3 align="center">PANEL-3 </h3>
<asp:Label ID="Label3" runat="server" Text="Stream You Have Selected Is
:"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server" Text="BCOM"></asp:Label><br />

</asp:Panel>
</td>
</tr>
</table>
</div>
</form>
</body> </html>

Prg2.aspx.vb :

Partial Class prg2


Inherits System.Web.UI.Page
Protected Sub rdstream_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rdstream.SelectedIndexChanged
Dim i As Integer
Dim st As String
For i = 0 To rdstream.Items.Count - 1
If rdstream.Items(0).Selected Then
Panel1.Visible = True
End If
Next
For i = 0 To rdstream.Items.Count - 1
If rdstream.Items(1).Selected Then
Panel2.Visible = True
End If
Next
For i = 0 To rdstream.Items.Count - 1
If rdstream.Items(2).Selected Then
Panel3.Visible = True
8
DAVE PRITA.
ASP.NET TYBCA_SEM-5

End If
Next
End Sub

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


Handles Me.Load
Panel1.Visible = False
Panel2.Visible = False
Panel3.Visible = False
End Sub
End Class

Output :

9
DAVE PRITA.
ASP.NET TYBCA_SEM-5

3. Create The Webpage Using Multiview Control And Display Following 3


Different Views On A Single Web Page.
Design :

Code:
multiviewpage.aspx :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mutliviewpage.aspx.vb"
Inherits="mutliviewpage" %>

<!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></title>
<style type="text/css">
.style1
{
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:MultiView ID="MultiView1" runat="server">


<asp:View ID="View1" runat="server">

10
DAVE PRITA.
ASP.NET TYBCA_SEM-5

<table colspan="5">
<tr>
<td>name</td>
<td> <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<br />
</td></tr>
<tr>
<td>
age</td>
<td>
<asp:TextBox ID="txtage" runat="server"></asp:TextBox>
<br />
</td></tr>
<tr>
<td>
address</td>
<td>
<asp:TextBox ID="txtaddress" runat="server"></asp:TextBox>
<br />
</td></tr>
<tr>
<td>
<asp:Button ID="btnnext" runat="server" Text="&gt;" />
</td> </tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
<table>
<tr>
<td> phone</td>
<td><asp:TextBox ID="txtphone" runat="server"></asp:TextBox>
<br /></td></tr>
<tr>
<td>
email</td>
<td> <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<br /></td>
</tr>
<tr>
<td>
<asp:Button ID="btnnext1" runat="server" Text="&lt;" /></td>
<td> <asp:Button ID="btnprev" runat="server" Text="&gt;" /></td>
</tr>
</table>

11
DAVE PRITA.
ASP.NET TYBCA_SEM-5

</asp:View>
<asp:View ID="View3" runat="server">
<center>
<h1>
summery</h1>
</center>
<table>
<tr><td>name</td>
<td>
<asp:Label ID="lblname" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style1" >
age</td>

<td class="style1" >


<asp:Label ID="lblage" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td >address</td>
<td >
<asp:Label ID="lbladd" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td > <asp:Label ID="lblss" runat="server"
Text="phone"></asp:Label></td>
<td >
<asp:Label ID="lblphone" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td > <asp:Label ID="lbllll" runat="server"
Text="email"></asp:Label></td>
<td > <asp:Label ID="lblemail" runat="server"
Text="Label"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Button ID="btnprev1" runat="server" Text="&lt;" />
</td>
<td>
<asp:Button ID="btnsub" runat="server" Text="finish" />

12
DAVE PRITA.
ASP.NET TYBCA_SEM-5

</td>
</tr>
</table>
</asp:View>
</asp:MultiView>

</div>
</form>
</body>
</html>

multiviewpage.
aspx.vb :

Partial Class mutliviewpage


Inherits System.Web.UI.Page

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


Handles Me.Load
If IsPostBack = False Then
MultiView1.ActiveViewIndex = 0
End If
End Sub

Protected Sub btnnext_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnnext.Click
MultiView1.ActiveViewIndex = 1
End Sub

Protected Sub btnnext1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnnext1.Click
MultiView1.ActiveViewIndex = 0
End Sub

Protected Sub btnprev_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnprev.Click
MultiView1.ActiveViewIndex = 2
End Sub

13
DAVE PRITA.
ASP.NET TYBCA_SEM-5

Protected Sub btnprev1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnprev1.Click
MultiView1.ActiveViewIndex = 1
End Sub

Protected Sub btnsub_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnsub.Click
lblname.Text = txtname.Text

lblage.Text = txtage.Text

lbladd.Text = txtaddress.Text

lblphone.Text = txtphone.Text

lblemail.Text = txtemail.Text

End Sub End

Class Output :

14
DAVE PRITA.
ASP.NET TYBCA_SEM-5

4. Create The Registration Form Using Tabular Format And When User
Submit The Form Display Data In A Separate Panel On The Same Page.
Also Apply All The Equired Validation Controls And Display Appropriate
Message.
Design :

Code:
Prg4.aspx :

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="prg4.aspx.vb"


Inherits="prg4" %>

<!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: 26px;
}

15
DAVE PRITA.
ASP.NET TYBCA_SEM-5

.style2
{
height: 26px;
width: 540px; }
.style3
{
width: 540px;
}
.style4
{
height: 48px;
}
.style5
{
width: 540px;
height: 48px;
}
.style6
{
height: 32px;
}
.style7
{
width: 540px;
height: 32px;
}
</style>
<script type="text/javascript" language="javascript">
function checkpasslen(sender, args) { if
(args.Value.Length < 8) args.IsValid = False;
else
args.IsValid = True;
}
</script> </head>
<body>
<form id="form1" runat="server">
<div>
<table style="height: 496px; width: 545px">
<tr>
<td align="center" colspan="2"><h1>Students Information</h1></td>
</tr>
<tr>
<td class="style1">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td>

16
DAVE PRITA.
ASP.NET TYBCA_SEM-5

<td class="style2">
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Name is Required" ControlToValidate="txtname"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>

</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="E-mail"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="email is Required" ControlToValidate="txtemail"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label3" runat="server" Text="Address"></asp:Label></td>
<td class="style5">
<asp:TextBox ID="txtaddress" runat="server"
TextMode="MultiLine"></asp:TextBox> <asp:RequiredFieldValidator
ID="RequiredFieldValidator3" runat="server"
ErrorMessage="address is Required" ControlToValidate="txtaddress"
ForeColor="Red"></asp:RequiredFieldValidator></td>

</tr>
<tr>
<td><asp:Label ID="Label19" runat="server" Text="Age"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtage" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ErrorMessage="age is Required" ControlToValidate="txtage"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="txtage" ErrorMessage="Age Must be Greater than 18"
ForeColor="Red" MaximumValue="100" MinimumValue="18"
Type="Integer"></asp:RangeValidator>

17
DAVE PRITA.
ASP.NET TYBCA_SEM-5

<br />
</td>
</tr>
<tr>
<td class="style6"><asp:Label ID="Label4" runat="server"
Text="Password"></asp:Label></td>
<td class="style7">
<asp:TextBox ID="txtpwd" runat="server"
TextMode="Password"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator2" runat="server"
ControlToValidate="txtpwd" ClientValidationFunction="checkpasslen"
ErrorMessage="password must contains 8 charcters"
ValidateEmptyText="true"
ForeColor="Red"></asp:CustomValidator>

</td>
</tr>
<tr>
<td><asp:Label ID="Label12" runat="server" Text="Confirm
Password"></asp:Label></td>
<td class="style3">
<asp:TextBox ID="txtcpwd" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ErrorMessage="confirm password is Required" ControlToValidate="txtcpwd"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtpwd" ControlToValidate="txtcpwd"
ErrorMessage="Password and Confirm password must be same"
ForeColor="Red"></asp:CompareValidator>
</td>
</tr>
<tr>
<td><asp:Label ID="Label5" runat="server" Text="Gender"></asp:Label></td>

<td class="style3">
<asp:RadioButtonList ID="radio_gender" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>

18
DAVE PRITA.
ASP.NET TYBCA_SEM-5

</tr>
<tr>
<td style="font-size: small">
<asp:Label ID="Label6" runat="server" Text="Hobby"></asp:Label></td>
<td class="style3">
<asp:CheckBoxList ID="chkbox_hobby" runat="server">
<asp:ListItem>Cricket</asp:ListItem>
<asp:ListItem>Hockey</asp:ListItem>
<asp:ListItem>Football</asp:ListItem>
<asp:ListItem>Volleyball</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>

<tr>
<td colspan="2" align="center">
<asp:Button ID="btnsubmit" runat="server" Text="Submit" />

<asp:Button ID="btnreset" runat="server" Text="Reset" /></td>


</tr>
<tr>
<td colspan="2">
<asp:Panel ID="Panel1" runat="server" Visible="False">
<h1 align="center">Output</h1>
<asp:Label ID="Label7" runat="server"
Text="Name"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblname" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label8" runat="server"
Text="Email"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblemail" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label9" runat="server"
Text="Address"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lbladdress" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label10" runat="server"
Text="Gender"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblgender" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label11" runat="server"
Text="Hobby"></asp:Label>&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblhobby" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
</div>

19
DAVE PRITA.
ASP.NET TYBCA_SEM-5

</form>
</body> </html>

Prg4.aspx.vb :

Partial Class prg4


Inherits System.Web.UI.Page
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnsubmit.Click
Panel1.Visible = True
Dim i As Integer
Dim gen As String
For i = 0 To radio_gender.Items.Count - 1
If radio_gender.Items(i).Selected Then
gen = radio_gender.Items(i).ToString
End If
Next

Dim str As String = ""


For i = 0 To chkbox_hobby.Items.Count - 1
If chkbox_hobby.Items(i).Selected Then
str += chkbox_hobby.Items(i).Text + " "
End If
Next
lblname.Text = txtname.Text
lblemail.Text = txtemail.Text
lbladdress.Text = txtaddress.Text
lblgender.Text = gen
lblhobby.Text = str

End Sub
Protected Sub btnreset_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnreset.Click
txtname.Text = ""
txtemail.Text = ""
txtaddress.Text = ""
txtpwd.Text = "" txtcpwd.Text
= ""
radio_gender.ClearSelection()
chkbox_hobby.ClearSelection()

End Sub
Protected Sub CustomValidator2_ServerValidate(ByVal source As Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CustomValidator2.ServerValidate

20
DAVE PRITA.
ASP.NET TYBCA_SEM-5

If (args.Value.Length < 8) Then


args.IsValid = False
End If
End Sub
End Class

Output :

21
DAVE PRITA.
ASP.NET TYBCA_SEM-5

5. Create A Web Page To Make The Use Of Calendar Control To Select


Your Birth Date And Display It On The Label. Design:

Code:
Prg5.aspx :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="prg5.aspx.vb"
Inherits="prg5" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Select Your Birthdate</h3>
<asp:Calendar ID="calBirthDate" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged" ></asp:Calendar>
<br />
<br />
<asp:Label ID="outputdate" runat="server" Text=""></asp:Label>

</div>
</form>
22
DAVE PRITA.
ASP.NET TYBCA_SEM-5

</body>
</html>
Prg5.aspx.vb :

Partial Class prg5


Inherits System.Web.UI.Page

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As


System.EventArgs) Handles calBirthDate.SelectionChanged
outputdate.Text = "Selected Birth Date: " +
calBirthDate.SelectedDate.ToShortDateString()
End Sub End
Class Output:

23
DAVE PRITA.
ASP.NET TYBCA_SEM-5

6. Create A Webpage That Enables You To Upload A File On The Server.

Design :

Code:
Prg6.aspx :
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Dim dir As String = "\img\"
Dim app_path As String = Request.PhysicalApplicationPath
If FileUpload1.HasFile = True Then
Dim save_path As String = app_path + dir +
Server.HtmlEncode(FileUpload1.FileName)
FileUpload1.SaveAs(save_path)
lbl.Text = "Successfully uploaded."
Else lbl.Text = "not uploaded."
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>

24
DAVE PRITA.
ASP.NET TYBCA_SEM-5

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


<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
</div>
<asp:Button ID="btnsubmit" runat="server" onclick="btnsubmit_Click"
Text="submit" />
<br />
<asp:Label ID="lbl" runat="server" Text="Label"></asp:Label>
</form>
</body> </html>
Output :

25
DAVE PRITA.

You might also like