A simple page

S

Slim

I have a simple page with a button.

when the button is clicked it creates a new button, all works fine so far

When the second button is clicked it should create a third button, but this
is where it fails.

How should I go about getting this to work



Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

bt2 = New Button

bt2.Text = "Button2"

AddHandler bt2.Click, AddressOf bt2Click

form1.Controls.Add(bt2)

End Sub

Sub bt2Click(ByVal sender As Object, ByVal e As System.EventArgs)

bt3 = New Button

bt3.Text = "Button3"

form1.Controls.Add(bt3)

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top