0% found this document useful (0 votes)
83 views

Lab Manual

The document describes creating a multiple choice questionnaire web form in ASP.NET with Visual Basic. It includes steps to create a new project, add a web form, add labels and radio button lists to the form for questions, and submit and display the score. The questions cover features of local variables and the purpose of the web.config file.

Uploaded by

Krish Sugi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Lab Manual

The document describes creating a multiple choice questionnaire web form in ASP.NET with Visual Basic. It includes steps to create a new project, add a web form, add labels and radio button lists to the form for questions, and submit and display the score. The questions cover features of local variables and the purpose of the web.config file.

Uploaded by

Krish Sugi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Exercise 1: Procedure for creating Home page for XYZ Corporation using web controls

Aim: To create a home page for XYZ corporation using web controls

Step 1: Launch VS.Net

Start-> Programs->visual studio.net

Step 2: Create a new project

1) Select file ->New->Project->Visual Basic->Web->ASP.NET web Application


2) Give name to the project “Exercise1” Press ok button.

Step 3: Add a web form to the project

1) In the solution explorer window right click the project name(exercise1) and select
Add->Add new item->web form.
2) Give name to the web form “XYZhomepage” press ok button.
3) Enter the web form design coding in the source side. Or design the web form as given in
the design side. Add the following controls
Label1,Label2,…Label9. RadioButtonList1,Calender,imagebutton and Button1.

Control property value


Label1 Text XYZ Corporation
Label2 Text Leaders in web solutions for business
Label3 Text Take our survey
Label4 Text Your feedback is important to us
Please take a moment to rate us
On the usefulness of our website
Label5 Text How useful is the XYZ corporation website?
Label6 ID Lblfeedback
Label7 text XYZ World tour
Label8 text Showcasing our latest products
Click on a date below
Label9 id lblevents
Radiobutt id Rblsurvey
onlist1 Item->add->text=very useful
Item->add->text=somewhat useful
Item->add->text=not useful at all
Imagebutt imageurl Images/desert.jpg
on1
Button1 Text Send feedback
id btnfeedback
Calender1

Design Code:

<%@ Page Language="vb" AutoEventWireup="false" Debug="true"


CodeBehind="XYZhomepage.aspx.vb" Inherits="Exercise1.XYZhomepage" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<p align="center">
<asp:Label ID="Label1" runat="server" Text="XYZ CORPORATION" Font-
Bold="True" Font-Names="Bookman Old Style" Font-Size="Larger"
forecolor="Blue"></asp:Label><br />
<asp:Label ID="Label2" runat="server"
text="Leaders in Web Solutions for Business"
Forecolor="Red"></asp:Label>
</p>
<p align="left">
<asp:Label ID="Label3" runat="server" text="Take our Survey" font-
Bold="True" Forecolor="#33CC33" Font-Overline="False" Font-
underline="True"></asp:Label><br />
<asp:Label ID="Label4" runat="server" Text="Your Feedback is important to
us <br /> Please take a moment to rate us<br /> on the usefulness of our
website." forecolor="#FF3399"></asp:Label><br />
<asp:Label ID="Label5" runat="server" Text="How useful is the XYZ
corporation Website>" font-Bold="true" forecolor="#99CCFF"></asp:Label>
<asp:RadioButtonList ID="rblsurvey" runat="server">
<asp:ListItem>Very Useful<</asp:ListItem>
<asp:ListItem>Some What Useful</asp:ListItem>
<asp:ListItem>Not Useful at all</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="lblfeedback" runat="server" Text="Label" Font-Bold="true"
ForeColor="#33CC33"></asp:Label>
<BR />
<asp:Button ID="btnfeedback" runat="server" Text="Send Feedback"/>
</p>
<p align="right">
<asp:Label ID="label7" runat="server" Text="XYZ World Tour" Font-
Bold="true" ForeColor="Red" Font-Underline="true"></asp:Label><br />
<asp:Label ID="Label8" runat="server" Text="Showcasing our latest
products<br />click on a date below" ForeColor="#8CC00FF"></asp:Label>
<asp:Calendar ID="Calender1" runat="server" Height="135px"
Width="234px"></asp:Calendar>
<asp:Label ID="lblevents" runat="server" Text="Label"></asp:Label>

</p>
<br />
</form>
</body>
</html>

Source Code:

Public Partial Class XYZhomepage


Inherits System.Web.UI.Page

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


System.EventArgs) Handles Me.Load

End Sub
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As EventArgs) Handles Calender1.SelectionChanged
Dim strdate As String
strdate = FormatDateTime(Calender1.SelectedDate, DateFormat.ShortDate)
Select Case strdate
Case "13-09-2021"
lblevents.Text = strdate + "new product demonstration"
Case Else
lblevents.Text = strdate + "no event on this date"
End Select

End Sub

Output:

Exercise 2: create a login page using user control in a web form

Aim: To create a login page using user control

In this article, we will see how to create a user control for ASP.NET. A user control is a custom,
reusable control in ASP.NET, saved in a file with an extension.ascx. you can reuse the Design
as well as code in the application With the help of the user control. They cannot run on their own
and they need to stand on another platform like an aspx page. Web user controls are derived
from System.Web.UI.User Control namespace.

Step 1: Launch VS.Net

Start-> Programs->visual studio.net


Step 2: Create a new project

1) Select file ->New->Project->Visual Basic->Windows Forms Control Library


2) Give name to the project “MyControlLibraray” Press ok button.

Step 3: Add a user control to a project

1) In the solution explorer window right click the project name(MyControlLibrary)


2) Give rename to the user control “login” press ok button.
3) Design login page

Source Code

Public Class Login


Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim u, p As String
u = TextBox1.Text
p = TextBox2.Text
If u = "admin" And p = "admin" Then
MsgBox("correct")
Else
MsgBox("incorrect")
End If
End Sub
End Class

Step 4: Add another user control

1) Click project->add usercontrol-> name it colorcontrol


2) Design colorcontrol.vb
Source Code

Public Class colorcontrol

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Label1.ForeColor = Color.Red
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Label1.ForeColor = Color.Green
End Sub
End Class

Save all the usercontrols

Step 5. Select Build -> build MyControlLibrary

1) In the output windows the location of mycontrollibrary.dll file is shown

Step 6: new->project->windows application

1) New form window open


2) Search textbox whether colorcontrol and logincontrol is there if not
3) Double click any one of the toolbox control
4) Toolbox items window open search and select login control and color control option
5) Now drag and drop that control in windows form
6) Build the application check the output

Output:
Exercise 3: create a simple multiple choice questionnaire.

Aim: To create a MCQ questionnaire. Submit and display the score.

Procedure:

Step 1: Launch VS.Net

Start-> Programs->visual studio.net

Step 2: Create a new project

3) Select file ->New->Project->Visual Basic->Web->ASP.NET web Application


4) Give name to the project “Exercise3” Press ok button.

Step 3: Add a web form to the project

4) In the solution explorer window right click the project name(exercise1) and select
Add->Add new item->web form.
5) Give name to the web form “Questionnaire” press ok button.

Enter the web form design coding in the source side.

Design Code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb"


Inherits="Exercise3.WebForm1" %>

<!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>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Panel ID="Panel1" runat="server" Height="763px">


<br />
<asp:Label ID="Label1" runat="server" Text="1) Feature of a Local
Variable"></asp:Label>
<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>It can be used anywhere in the
program</asp:ListItem>
<asp:ListItem>It must accept a class</asp:ListItem>
<asp:ListItem>It must be declared within a
method</asp:ListItem>
<asp:ListItem>It represent a class object</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label2" runat="server"
Text="2) Web.config file is used
_________________."></asp:Label>
<asp:RadioButtonList ID="RadioButtonList2" runat="server">
<asp:ListItem>Configures the time that the server side code
behind module</asp:ListItem>
<asp:ListItem>to store the global information and variable
definition for the
application</asp:ListItem>
<asp:ListItem>To configure the web server</asp:ListItem>
<asp:ListItem>To configure the web browser</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label3" runat="server"
Text="3) File extension used for ASP.NET files."></asp:Label>
<asp:RadioButtonList ID="RadioButtonList3" runat="server">
<asp:ListItem>.Web</asp:ListItem>
<asp:ListItem>.asp</asp:ListItem>
<asp:ListItem>.aspx</asp:ListItem>
<asp:ListItem>None</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label4" runat="server"
Text="4) An alternative way of displaying text on web page
using"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList4" runat="server">
<asp:ListItem>asp:Label</asp:ListItem>
<asp:ListItem>asp:Listitem</asp:ListItem>
<asp:ListItem>asp:Button</asp:ListItem>
<asp:ListItem>asp:List</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label5" runat="server"
Text="5)The .NET Framework provides a runtime environment
called ______________________ ?"></asp:Label>
<br />
<asp:RadioButtonList ID="RadioButtonList5" runat="server">
<asp:ListItem>RMT</asp:ListItem>
<asp:ListItem>CLR</asp:ListItem>
<asp:ListItem>CLS</asp:ListItem>
<asp:ListItem>CTS</asp:ListItem>
</asp:RadioButtonList>
<br />
<p align="center">
<asp:Button ID="Button1" runat="server" Text="Score" />
</p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

</asp:Panel>

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

Source code:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)


Handles Button1.Click
Dim score = 0
If RadioButtonList1.SelectedIndex = 0 Then
score = score + 1
If RadioButtonList2.SelectedIndex = 1 Then
score = score + 1
If RadioButtonList3.SelectedIndex = 2 Then
score = score + 1
If RadioButtonList4.SelectedIndex = 3 Then
score = score + 1
If RadioButtonList5.SelectedIndex = 0 Then
score = score + 1
End If
End If
End If
End If
End If
MsgBox(score)
End Sub

Output:
Exercise 4: Develop a project give input and Retrieve output from database

Aim: To develop a project to input data through a web form to a database and retrieve the data.
Use the calendar control to input date.

Procedure:

Step 1:

Exercise 6: Check whether a given word or phrase is a palindrome using web service

Aim: Check whether a given word or phrase is a palindrome or not

Procedure:

Step 1: Launch VS.Net

Start-> Programs->visual studio.net

Step 2: Create a new project

5) Select file ->New->Project->Visual Basic->Web->ASP.NET web Application


6) Give name to the project “Exercise6” Press ok button.

Step 3: Add a web form to the project

6) In the solution explorer window right click the project name(exercise6) and select
Add->Add new item->web form.
7) Give name to the web form “Palindrome” press ok button.

Enter the web form design coding in the source side.


Design Code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb"
Inherits="Exercise4._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>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 180px">

<asp:Label ID="Label1" runat="server" Text="Check Palindrome


"></asp:Label>
&nbsp;&nbsp;
<br />
<br />
String&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" Height="29px"
Width="206px"></asp:TextBox>
&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Check" />
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Number"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" Height="36px"
Width="198px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="Check" />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
<br />

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

Source Code

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)


Handles Button2.Click
Dim n As Integer
n = TextBox2.Text
Dim temp As Integer
Dim reverse As Integer
temp = n
Dim remainder As Integer
While (temp <> 0)
remainder = temp Mod 10
reverse = reverse * 10 + remainder
temp = temp / 10
End While
If (reverse = n) Then
Label2.Text = "is palindrome"
Else
Label2.Text = "is not a palindrome"
End If

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)


Handles Button1.Click
Dim n As String
n = TextBox1.Text
If n = StrReverse(n) Then
label2.text = n & "is palindrome"
Else
label2.text = n & "is not a palindrome"
End If
End Sub

Output:
Exercise 7: Create a Online photo gallery using Data list and Data grid control

Aim: Create a photo gallery

Procedure:

You might also like