Here is what we did in class
Default.aspx source
<%@ 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>Fruit flies</title>
<link href="fruit.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Fruit</h1>
<asp:BulletedList ID="BulletedList1" runat="server">
</asp:BulletedList>
</div>
<asp:Label ID="Label1" runat="server" Text="Enter Price"></asp:Label>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox><br />
<asp:Label ID="Label2" runat="server" Text="Enter Quantity"></asp:Label><asp:TextBox
ID="txtquantity" runat="server"></asp:TextBox> <br />
<asp:Button ID="Button1" runat="server" Text="Calculate" /> <br />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</form><br />
</body>
</html>
Default.aspx.vb
Option Strict On
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim fruit() As String = {"apple", "pear", "mango", "banana", "starfruit", "strawberry"}
BulletedList1.DataSource = fruit
BulletedList1.DataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim price As Double
Dim quantity As Integer
If Not Double.TryParse(txtPrice.Text, price) Then
Label3.Text = "invalid Price"
Return
End If
If Not Integer.TryParse(txtquantity.Text, quantity) Then
Label3.Text = "Invalid Quantity"
Return
End If
Label3.Text = (price * quantity).ToString("$#,###.00")
End Sub
End Class
Fruit.css
body {
}
li
{
font-size:150%;
color:Purple;
}
No comments:
Post a Comment