<%@ 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:Label ID="Label1" runat="server" Width="147px"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" Width="98px" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<br />
<asp:Table ID="Table1" runat="server" Height="88px" Width="166px">
</asp:Table>
<br />
<asp:Button ID="Button2" runat="server" Text="Button" Width="93px" /><br />
</div>
</form>
</body>
</html>
File: Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Private Property myCounter() As Integer
Get
Return CInt(Cache("myCounter"))
End Get
Set(ByVal Value As Integer)
Cache("myCounter") = Value
End Set
End Property
Private ReadOnly Property RowTexts() As ArrayList
Get
Dim al As ArrayList
al = CType(Cache("rowTexts"), ArrayList)
If IsNothing(al) Then
al = New ArrayList()
Cache("rowTexts") = al
End If
Return al
End Get
End Property
Private Sub AddARow(ByVal s As String)
Dim cell As New TableCell()
Dim row As New TableRow()
cell.Text = s
row.Cells.Add(cell)
Table1.Rows.Add(row)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
myCounter += 1
Label1.Text = myCounter.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
RowTexts.Add(TextBox1.Text)
AddARow(TextBox1.Text)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim s As String
For Each s In RowTexts
AddARow(s)
Next
End Sub
End Class