Lab 9 Code

CheckBox.aspx

code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CheckBox.aspx.vb" Inherits="CheckBox" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CheckBox Test</title> <style> body { font-family: Arial, sans-serif; margin: 30px; } .container { padding: 20px; border: 1px solid #ccc; width: 400px; background-color: #f9f9f9; } .result-label { margin-top: 15px; color: #333; } </style> </head> <body> <form id="form1" runat="server"> <div class="container"> <asp:Label ID="lbl1" runat="server" Text="Choose Options:"></asp:Label> <br /><br /> <asp:CheckBoxList ID="LangCheckBoxList" runat="server"> <asp:ListItem>C</asp:ListItem> <asp:ListItem>C++</asp:ListItem> <asp:ListItem>C#</asp:ListItem> <asp:ListItem>Visual Basic 6.0</asp:ListItem> <asp:ListItem>VB.NET</asp:ListItem> <asp:ListItem>Pascal</asp:ListItem> </asp:CheckBoxList> <br /> <asp:Button ID="SubmitButton" runat="server" Text="OK" OnClick="Button1_Click" /> <br /><br /> <asp:Label ID="lbl2" runat="server" CssClass="result-label" Font-Bold="True" ForeColor="Black"></asp:Label> </div> </form> </body> </html>

CheckBox.aspx.vb

code

Partial Class CheckBox
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim selectedItems As String = "Your choosen options:<br />"

For Each item As ListItem In LangCheckBoxList.Items
If item.Selected Then
selectedItems &= item.Text "<br />"
End If
Next

lbl2.Text = selectedItems
End Sub
End Class

TableGen.aspx

code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TableGen.aspx.vb" Inherits="TableGen" %> <html> <head> <title>Table Generator</title> <style> body { font-family: Arial, sans-serif; margin: 30px; } .input-area { margin-bottom: 20px; } .table-style { margin-top: 20px; } </style> </head> <body> <form id="form1" runat="server"> <h3>Generate Table</h3> <div class="input-area"> Rows: <asp:TextBox ID="rowBox" runat="server" Width="50px" /> Cols: <asp:TextBox ID="colBox" runat="server" Width="50px" /> <br /><br /> <asp:CheckBox ID="borderCheck" runat="server" Text="Border" /> <br /><br /> <asp:Button ID="makeBtn" runat="server" Text="Create Table" OnClick="btnCreate_Click" /> </div> <asp:Table ID="myTable" runat="server" CssClass="table-style" /> </form> </body> </html>

TableGen.aspx.vb

code

Partial Class TableGen
Inherits System.Web.UI.Page

Protected Sub btnCreate_Click(sender As Object, e As EventArgs)
myTable.Rows.Clear()

Dim rows As Integer = Integer.Parse(rowBox.Text)
Dim cols As Integer = Integer.Parse(colBox.Text)

For i As Integer = 0 To rows - 1
Dim tr As New TableRow()
For j As Integer = 0 To cols - 1
Dim td As New TableCell()
Dim myLabel As New Label()
myLabel.Text = "Cell " & i "," & j
td.Controls.Add(myLabel)

If borderCheck.Checked Then
td.BorderStyle = BorderStyle.Solid
td.BorderWidth = Unit.Pixel(1)
End If

tr.Cells.Add(td)
Next
myTable.Rows.Add(tr)
Next
End Sub
End Class
Web hosting by Somee.com