tycs visual basic practicals
TRANSCRIPT
T.Y. BSc Computer Science
Practical No: 1
Practical Name: A software company wants to conduct placements for graduates in Mumbai or
Pune. Design an HTML page to input student details such as name using
textbox, course name such as BSc Comp Sci/IT/Phy/Maths using radio button,
Marks in SSC,HSC, FY & SY along with Year of Passing using text boxes &
Location such as Mumbai/Pune using combo box. The student is shortlisted
only if he/she has min 60% in SSC & HSC, FY & SY average should be min
55% & there should not be any gap in education. When student clicks on
Register button, the data is submitted to ASP.NET page which informs the
student whether he/she qualifies and place of interview in Mumbai or Pune as
given by the student.
Date:
Source Code:
Default.aspx.vb:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim m1, y2, m3, y4, m5, y6, m7, y8 As Integer
m1 = Integer.Parse(TextBox3.Text)
y2 = Integer.Parse(TextBox4.Text)
m3 = Integer.Parse(TextBox5.Text)
y4 = Integer.Parse(TextBox6.Text)
m5 = Integer.Parse(TextBox7.Text)
y6 = Integer.Parse(TextBox8.Text)
m7 = Integer.Parse(TextBox9.Text)
y8 = Integer.Parse(TextBox10.Text)
If m1 > 60 And m3 > 60 And (m5 + m7) / 2 > 55 And y8 - y2 = 4 Then
T.Y. BSc Computer Science
TextBox11.Text = "illigible"
Else
TextBox11.Text = "not Illigible"
End If
If DropDownList2.Text = "Mumbai" Then
Label3.Text = "M.D College"
ElseIf DropDownList2.Text = "Pune" Then
Label3.Text = "ChatrapatiShivaji College"
ElseIf DropDownList2.Text = "Kharghar" Then
Label3.Text = "Kharghar University"
Else
Label3.Text = "Y. C college"
End If
End Sub
End Class
Output:
T.Y. BSc Computer Science
Practical No: 2
Practical Name: Write a program to use all validation controls.
Date:
Source Code:
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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 style="height: 458px">
<form id="form1" runat="server">
<div style="height: 387px">
Customer Name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Please Enter The Name"
ForeColor="Green" SetFocusOnError="True"></asp:RequiredFieldValidator>
<br />
<br />
Contact
No: &nb
sp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Please Enter The Contact Number"
ForeColor="Green" SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Enter 10 digi Contact no"
ForeColor="Red" SetFocusOnError="True" ValidationExpression="[0-
9]{10}"></asp:RegularExpressionValidator>
<br />
<br />
T.Y. BSc Computer Science
Email: &
nbsp; &n
bsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Enter your e-Mail "
ForeColor="Green" SetFocusOnError="True"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
<br />
<br />
Date of
Brith: &n
bsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox4" ErrorMessage="Enter The Birth Date"
ForeColor="Green" MaximumValue="12/02/2016" MinimumValue="12/01/2000"
SetFocusOnError="True" Type="Date"></asp:RangeValidator>
<br />
<br />
User
Name: &
nbsp;
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox5" ErrorMessage="Please Enter User Name"
ForeColor="Green" SetFocusOnError="True"></asp:RequiredFieldValidator>
<br />
<br />
Password: &nbs
p;
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox6" ErrorMessage="Please Enter The Password"
ForeColor="Green" SetFocusOnError="True"></asp:RequiredFieldValidator>
<br />
<br />
Confirm Password:
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox6" ControlToValidate="TextBox7"
ErrorMessage="Password not match" ForeColor="Green" SetFocusOnError="True"
ValueToCompare="TextBox7"></asp:CompareValidator>
T.Y. BSc Computer Science
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Store Data" />
</div>
</form>
</body>
</html>
Output:
T.Y. BSc Computer Science
Practical No: 3
Practical Name: Write a program to create a web site with AdRotator.
Date:
Source Code:
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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 style="height: 229px">
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
</div>
</form>
</body>
</html>
XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>Dance image/images.jpeg</ImageUrl>
<NavigateUrl>https://www.freewebsitetemplates.com/..</NavigateUrl>
<AlternateText>
Dance info
</AlternateText>
<Keyword>Info</Keyword>
T.Y. BSc Computer Science
</Ad>
<Ad>
<ImageUrl>Dance image/sing_501.jpg</ImageUrl>
<NavigateUrl>https://www.singsnap.com</NavigateUrl>
<AlternateText>
Sing info
</AlternateText>
<Keyword>info</Keyword>
</Ad>
</Advertisements>
Output:
T.Y. BSc Computer Science
Practical No: 4
Practical Name: Develop a web page for a real estate firm that accepts information of flats to
be sold such as City, No. of Rooms, Expected Price and stores it in a database.
Another web page that shows a combo box containing the list of cities. When
you select a city, show the flats available in the city. [Use data binding and data
source].
Date:
Source Code:
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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 style="height: 533px">
<form id="form1" runat="server">
<div style="height: 596px">
<br />
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>kharghar</asp:ListItem>
<asp:ListItem>pune</asp:ListItem>
<asp:ListItem>vasi</asp:ListItem>
<asp:ListItem>thane</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px"
CellPadding="4" CellSpacing="2" DataSourceID="SqlDataSource1"
ForeColor="Black">
T.Y. BSc Computer Science
<Columns>
<asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
<asp:BoundField DataField="flat" HeaderText="flat" SortExpression="flat" />
<asp:BoundField DataField="room" HeaderText="room" SortExpression="room" />
<asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="Gray" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Flat] WHERE ([city] = @city)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="city"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>
<br />
<asp:Button ID="Button1" runat="server" Text="Press" />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Default2.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlCommand
Partial Class Default2
Inherits System.Web.UI.Page
T.Y. BSc Computer Science
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim str1 As String = "select * from Flat where city = '" &
DropDownList1.SelectedItem.Value & "'"
Label1.Text = str1
End Sub
End Class
Output:
Practical No: 5
T.Y. BSc Computer Science
Practical Name: A Cable TV provider stores the list of channels in an XML File. For each
Channel, there is an attribute “Name”. The Channel element consists of sub-
elements such as Languages(such as Hindi, English, Marathi etc),
Category(Sports, Movies, Cartoons etc). Design an ASP.NET page that
displays, the list of languages and categories in 2 combo boxes. When user
clicks a button, all the channels matching the selected criteria should be
displayed. Date:
Source Code:
Default.aspx.vb
Imports System.Xml
Imports System.IO
Partial Class Default2
Inherits System.Web.UI.Page
Dim doc As XmlDocument
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
doc = New XmlDocument
Label3.Text = ""
doc.Load("C:\Users\computerlab\Documents\Visual Studio
2010\WebSites\WebSite13\XMLFile.xml")
Dim element As XmlElement
For Each element In doc.DocumentElement.ChildNodes()
Dim ch As String
ch = element.GetAttribute("Name")
If element.ChildNodes(0).InnerText = DropDownList1.Text And
element.ChildNodes(1).InnerText = DropDownList2.Text Then
Label3.Text &= ch & ","
End If
Next
doc = Nothing
End Sub
End Class XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
T.Y. BSc Computer Science
<CableTv>
<Channel Name="Colours">
<Language>Hindi</Language>
<Category>Entertainment</Category>
</Channel>
<Channel Name="Star Plus">
<Language>Hindi</Language>
<Category>Entertainment</Category>
</Channel>
<Channel Name="POGO">
<Language>Hindi</Language>
<Category>Cartoon</Category>
</Channel>
<Channel Name="Life Ok">
<Language>Hindi</Language>
<Category>Entertainment</Category>
</Channel>
<Channel Name="StarSports">
<Language>English</Language>
<Category>Sports</Category>
</Channel>
</CableTv>
Output:
Before Clicking Show Button.
After Clicking Chow Button.
T.Y. BSc Computer Science
Practical No: 6
T.Y. BSc Computer Science
Practical Name:
Date:
Source Code:
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
The Today's cricket Match score - India Batting --<br />
<asp:Label ID="Label1" runat="server" Text="10"></asp:Label>
<br />
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
T.Y. BSc Computer Science
</div>
</form>
</body>
</html>
Design:
Output:
T.Y. BSc Computer Science
T.Y. BSc Computer Science
Practical No: 7
Practical Name: Use of gridview with paging and sorting
Date:
Source Code:
Default2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3"
DataSourceID="SqlDataSource1" EnableModelValidation="True"
EnableSortingAndPagingCallbacks="True" GridLines="Vertical" Width="460px">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="Emp_id" HeaderText="Emp_id"
SortExpression="Emp_id" />
<asp:BoundField DataField="Emp_Name" HeaderText="Emp_Name"
SortExpression="Emp_Name" />
<asp:BoundField DataField="Emp_Addres" HeaderText="Emp_Addres"
SortExpression="Emp_Addres" />
<asp:BoundField DataField="Emp_Gender" HeaderText="Emp_Gender"
SortExpression="Emp_Gender" />
<asp:BoundField DataField="Emp_phone" HeaderText="Emp_phone"
SortExpression="Emp_phone" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
T.Y. BSc Computer Science
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [EMP1]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Desing:
Output:
T.Y. BSc Computer Science
Practical No: 8
T.Y. BSc Computer Science
Practical Name: Use of calendar control
Date:
Source Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!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 Ur Select date..</h3>
<asp:Calendar ID="Calendar1" runat="server" CaptionAlign="Right"
FirstDayOfWeek="Sunday" NextPrevFormat="FullMonth"
SelectionMode="DayWeekMonth"
SelectMonthText="select month" SelectWeekText="select week"></asp:Calendar>
<br />
<br />
<br />
<h3> U Selected these dates..</h3>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
</div>
</form>
</body>
</html>
Calendar Source code:
Partial Class Default2
Inherits System.Web.UI.Page
T.Y. BSc Computer Science
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Calendar1.SelectionChanged
Label1.Text = ""
For Each d As DateTime In Calendar1.SelectedDates
Label1.Text &= d.ToString("D") & "<br/>"
Next
End Sub
End Class
Design:
Output:
Practical No: 9
T.Y. BSc Computer Science
Practical Name: ADO.NET in ASP.NET with data binding, interacting with XML
documents
Date:
Source code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<%@ Import Namespace="System.Data" %>
<!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">
<asp:Repeater ID="cdcatalog" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Country</th>
<th>Company</th>
<th>Price</th>
<th>Year</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
T.Y. BSc Computer Science
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#e8e8e8">
<td><%#Container.DataItem("title")%></td>
<td><%#Container.DataItem("artist")%></td>
<td><%#Container.DataItem("country")%></td>
<td><%#Container.DataItem("company")%></td>
<td><%#Container.DataItem("price")%></td>
<td><%#Container.DataItem("year")%></td>
</tr>
</AlternatingItemTemplate>
<SeparatorTemplate>
<tr>
<td colspan="6"><hr /></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div>
</div>
</form>
</body>
</html>
Xml cdcatlog:
<?xml version="1.0" encoding="utf-8" ?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
T.Y. BSc Computer Science
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd>
<title>Still got the blues</title>
<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
<cd>
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
</catalog>
View code :
Imports System.Data
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load() Handles Me.Load
If Not Page.IsPostBack Then
Dim mycdcatalog = New DataSet
mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))
cdcatalog.DataSource = mycdcatalog
cdcatalog.DataBind()
End If
End Sub
End Class
Design:
T.Y. BSc Computer Science
Output:
T.Y. BSc Computer Science