By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

addhandler problem

P: n/a
i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler to it.

but when button 2 is clicked nothing happens, why?

Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Dim test1 As Boolean = False

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)

Response.Write("Button 1")

End Sub

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

If test1 = True Then

Response.Write("Button 2")

End If

End Sub

End Class
Dec 30 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
When button2 is clicked, the page postback. At this point button2 doesn't
exist any more. You may think that the ViewState takes care of this, but it
only takes care of maintaing values, not actual controls.

You need to re-create button2 on or before the Load event and hook up it's
event handler to have it work. As a matter of fact, you don't even need to
do the AddHandler in the Button1 click, the AddHandler needs to be done on
postback before/during the load event.

One way people often do this is by storing values in the viewstate,
something like:

Button1_Click(...)
dim bt2 as button = new Button()
...
form1.Controls.Add(bt2)
ViewState.Add("LoadButton2", true)
end sub

OnLoad(...)
if Page.IsPostBack then
if not ViewState("LoadButton2") is nothing AndAlso
cbool(ViewState("LoadButton2")) == true then
dim bt2 as button = new Button()
Addhandler bt2.Click ....
Form1.Controls.Add(bt2)
end if
end if
end sub

Denis Bauer has a special PlaceHolderControl that will do all of this for
you. It's free:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

You should check it out and you might be interested in looking at thee
source code to gain a better fundamental understanding of how it works...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
>i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler to
it.

but when button 2 is clicked nothing happens, why?

Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Dim test1 As Boolean = False

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)

Response.Write("Button 1")

End Sub

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

If test1 = True Then

Response.Write("Button 2")

End If

End Sub

End Class

Dec 30 '06 #2

P: n/a
Thanks your example worked fine.
I did try something like this before that made the button persist but did
not add handlers, but all working fine now, thanks allot

"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:OC*************@TK2MSFTNGP04.phx.gbl...
When button2 is clicked, the page postback. At this point button2 doesn't
exist any more. You may think that the ViewState takes care of this, but
it only takes care of maintaing values, not actual controls.

You need to re-create button2 on or before the Load event and hook up it's
event handler to have it work. As a matter of fact, you don't even need to
do the AddHandler in the Button1 click, the AddHandler needs to be done on
postback before/during the load event.

One way people often do this is by storing values in the viewstate,
something like:

Button1_Click(...)
dim bt2 as button = new Button()
...
form1.Controls.Add(bt2)
ViewState.Add("LoadButton2", true)
end sub

OnLoad(...)
if Page.IsPostBack then
if not ViewState("LoadButton2") is nothing AndAlso
cbool(ViewState("LoadButton2")) == true then
dim bt2 as button = new Button()
Addhandler bt2.Click ....
Form1.Controls.Add(bt2)
end if
end if
end sub

Denis Bauer has a special PlaceHolderControl that will do all of this for
you. It's free:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

You should check it out and you might be interested in looking at thee
source code to gain a better fundamental understanding of how it works...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
>>i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler to
it.

but when button 2 is clicked nothing happens, why?

Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Dim test1 As Boolean = False

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)

Response.Write("Button 1")

End Sub

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

If test1 = True Then

Response.Write("Button 2")

End If

End Sub

End Class


Dec 31 '06 #3

P: n/a
Actualy i still have a problem

on this page
http://worldgolfdata.com/Enter/Default.aspx
i have a list of countries when you click on them you get a list of states,
click on a state youi get a list of golf courses from that state.

I have a little bit of test data in it, if you go to Australia, then select
either Victoria or Western Australia you will get a list of 1 or 2 courses
repectivly.

I also have a lale that shows what event handler has fired.

if you have a play you will se that when you change state from victoria to
western australia then click on a course the lable shows that the event
handler does not fire till you click the second time.

Can you tell me why and suggets a fix or a workaround?

here is the code

Partial Class Enter_Default
Inherits System.Web.UI.Page

Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
buildCountrys()
If ViewState("buildStates") <"" Then
buildStates()
End If
If ViewState("buildCourses") <"" Then
buildCourses()
End If
End Sub

Sub buildCountrys()
Dim oCountries As Countries
oCountries = New Countries
Dim i As Integer
For i = 0 To UBound(oCountries.getCountries)
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCountry As LinkButton = New LinkButton
AddHandler linkCountry.Click, AddressOf CountryButtClick
linkCountry.OnClientClick = "waitForIt()"
linkCountry.Attributes.Add("class", "dButtons")
linkCountry.CommandArgument = oCountries.getCountries(i).id
linkCountry.Text = oCountries.getCountries(i).Name
td.Controls.Add(linkCountry)
tr.Cells.Add(td)
countryTable.Rows.Add(tr)
Next
End Sub

Sub buildStates()
stateTable.Rows.Clear()
courseTable.Rows.Clear()
Dim oCountry As Country
oCountry = New Country(ViewState("buildStates"))
Dim i As Integer
For i = 0 To UBound(oCountry.getStates)
'On Error Resume Next
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkState As LinkButton = New LinkButton
AddHandler linkState.Click, AddressOf StateButtClick
linkState.OnClientClick = "waitForIt()"
linkState.Attributes.Add("class", "dButtons")
linkState.CommandArgument = oCountry.getStates(i).id
linkState.Text = oCountry.getStates(i).Name
td.Controls.Add(linkState)
tr.Cells.Add(td)
stateTable.Rows.Add(tr)
Next
End Sub

Sub buildCourses()
courseTable.Rows.Clear()
Dim oState As State
oState = New State(ViewState("buildCourses"))
Dim i As Integer
For i = 0 To UBound(oState.getCourses)
If oState.countCourses 0 Then
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCourse As LinkButton = New LinkButton
AddHandler linkCourse.Click, AddressOf CourseButtClick
linkCourse.OnClientClick = "waitForIt()"
linkCourse.Attributes.Add("class", "dButtons")
linkCourse.CommandArgument = oState.getCourses(i).id
linkCourse.Text = oState.getCourses(i).Name
td.Controls.Add(linkCourse)
courseTable.Rows.Add(tr)
tr.Cells.Add(td)
Else
End If
Next
End Sub

Sub CountryButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildStates", sender.CommandArgument)
Label1.Text = "country clicked"
buildStates()

End Sub

Sub StateButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildCourses", sender.CommandArgument)
Label1.Text = "state clicked"
buildCourses()

End Sub

Sub CourseButtClick(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = "course clicked"
End Sub

End Class

"Slim" <me@here.comwrote in message
news:O5**************@TK2MSFTNGP04.phx.gbl...
Thanks your example worked fine.
I did try something like this before that made the button persist but did
not add handlers, but all working fine now, thanks allot

"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:OC*************@TK2MSFTNGP04.phx.gbl...
>When button2 is clicked, the page postback. At this point button2 doesn't
exist any more. You may think that the ViewState takes care of this, but
it only takes care of maintaing values, not actual controls.

You need to re-create button2 on or before the Load event and hook up
it's event handler to have it work. As a matter of fact, you don't even
need to do the AddHandler in the Button1 click, the AddHandler needs to
be done on postback before/during the load event.

One way people often do this is by storing values in the viewstate,
something like:

Button1_Click(...)
dim bt2 as button = new Button()
...
form1.Controls.Add(bt2)
ViewState.Add("LoadButton2", true)
end sub

OnLoad(...)
if Page.IsPostBack then
if not ViewState("LoadButton2") is nothing AndAlso
cbool(ViewState("LoadButton2")) == true then
dim bt2 as button = new Button()
Addhandler bt2.Click ....
Form1.Controls.Add(bt2)
end if
end if
end sub

Denis Bauer has a special PlaceHolderControl that will do all of this for
you. It's free:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

You should check it out and you might be interested in looking at thee
source code to gain a better fundamental understanding of how it works...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
>>>i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler to
it.

but when button 2 is clicked nothing happens, why?

Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Dim test1 As Boolean = False

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)

Response.Write("Button 1")

End Sub

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

If test1 = True Then

Response.Write("Button 2")

End If

End Sub

End Class



Dec 31 '06 #4

P: n/a
Clicking australia doesn't bring anything up for me.

I would look at Denis Bauer's control if you are dealing with that many
dynamic controls.

An alternative would be to forgo the postback mechanism and simply use the
QueryString - this would have the added benefit of being
bookmarkable...sometimes old tricks work best.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:Od**************@TK2MSFTNGP06.phx.gbl...
Actualy i still have a problem

on this page
http://worldgolfdata.com/Enter/Default.aspx
i have a list of countries when you click on them you get a list of
states, click on a state youi get a list of golf courses from that state.

I have a little bit of test data in it, if you go to Australia, then
select either Victoria or Western Australia you will get a list of 1 or 2
courses repectivly.

I also have a lale that shows what event handler has fired.

if you have a play you will se that when you change state from victoria to
western australia then click on a course the lable shows that the event
handler does not fire till you click the second time.

Can you tell me why and suggets a fix or a workaround?

here is the code

Partial Class Enter_Default
Inherits System.Web.UI.Page

Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
buildCountrys()
If ViewState("buildStates") <"" Then
buildStates()
End If
If ViewState("buildCourses") <"" Then
buildCourses()
End If
End Sub

Sub buildCountrys()
Dim oCountries As Countries
oCountries = New Countries
Dim i As Integer
For i = 0 To UBound(oCountries.getCountries)
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCountry As LinkButton = New LinkButton
AddHandler linkCountry.Click, AddressOf CountryButtClick
linkCountry.OnClientClick = "waitForIt()"
linkCountry.Attributes.Add("class", "dButtons")
linkCountry.CommandArgument = oCountries.getCountries(i).id
linkCountry.Text = oCountries.getCountries(i).Name
td.Controls.Add(linkCountry)
tr.Cells.Add(td)
countryTable.Rows.Add(tr)
Next
End Sub

Sub buildStates()
stateTable.Rows.Clear()
courseTable.Rows.Clear()
Dim oCountry As Country
oCountry = New Country(ViewState("buildStates"))
Dim i As Integer
For i = 0 To UBound(oCountry.getStates)
'On Error Resume Next
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkState As LinkButton = New LinkButton
AddHandler linkState.Click, AddressOf StateButtClick
linkState.OnClientClick = "waitForIt()"
linkState.Attributes.Add("class", "dButtons")
linkState.CommandArgument = oCountry.getStates(i).id
linkState.Text = oCountry.getStates(i).Name
td.Controls.Add(linkState)
tr.Cells.Add(td)
stateTable.Rows.Add(tr)
Next
End Sub

Sub buildCourses()
courseTable.Rows.Clear()
Dim oState As State
oState = New State(ViewState("buildCourses"))
Dim i As Integer
For i = 0 To UBound(oState.getCourses)
If oState.countCourses 0 Then
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCourse As LinkButton = New LinkButton
AddHandler linkCourse.Click, AddressOf CourseButtClick
linkCourse.OnClientClick = "waitForIt()"
linkCourse.Attributes.Add("class", "dButtons")
linkCourse.CommandArgument = oState.getCourses(i).id
linkCourse.Text = oState.getCourses(i).Name
td.Controls.Add(linkCourse)
courseTable.Rows.Add(tr)
tr.Cells.Add(td)
Else
End If
Next
End Sub

Sub CountryButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildStates", sender.CommandArgument)
Label1.Text = "country clicked"
buildStates()

End Sub

Sub StateButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildCourses", sender.CommandArgument)
Label1.Text = "state clicked"
buildCourses()

End Sub

Sub CourseButtClick(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = "course clicked"
End Sub

End Class

"Slim" <me@here.comwrote in message
news:O5**************@TK2MSFTNGP04.phx.gbl...
>Thanks your example worked fine.
I did try something like this before that made the button persist but did
not add handlers, but all working fine now, thanks allot

"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:OC*************@TK2MSFTNGP04.phx.gbl...
>>When button2 is clicked, the page postback. At this point button2
doesn't exist any more. You may think that the ViewState takes care of
this, but it only takes care of maintaing values, not actual controls.

You need to re-create button2 on or before the Load event and hook up
it's event handler to have it work. As a matter of fact, you don't even
need to do the AddHandler in the Button1 click, the AddHandler needs to
be done on postback before/during the load event.

One way people often do this is by storing values in the viewstate,
something like:

Button1_Click(...)
dim bt2 as button = new Button()
...
form1.Controls.Add(bt2)
ViewState.Add("LoadButton2", true)
end sub

OnLoad(...)
if Page.IsPostBack then
if not ViewState("LoadButton2") is nothing AndAlso
cbool(ViewState("LoadButton2")) == true then
dim bt2 as button = new Button()
Addhandler bt2.Click ....
Form1.Controls.Add(bt2)
end if
end if
end sub

Denis Bauer has a special PlaceHolderControl that will do all of this
for you. It's free:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

You should check it out and you might be interested in looking at thee
source code to gain a better fundamental understanding of how it
works...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler to
it.

but when button 2 is clicked nothing happens, why?

Partial Class test_buttons

Inherits System.Web.UI.Page

Dim bt2 As Button

Dim bt3 As Button

Dim test1 As Boolean = False

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)

Response.Write("Button 1")

End Sub

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

If test1 = True Then

Response.Write("Button 2")

End If

End Sub

End Class


Dec 31 '06 #5

P: n/a

"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:OB**************@TK2MSFTNGP04.phx.gbl...
Clicking australia doesn't bring anything up for me.
you may of visited the site whne i was working on it.
I would look at Denis Bauer's control if you are dealing with that many
dynamic controls.

An alternative would be to forgo the postback mechanism and simply use the
QueryString - this would have the added benefit of being
bookmarkable...sometimes old tricks work best.
I would like to work it out al the same

thanks
>
Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:Od**************@TK2MSFTNGP06.phx.gbl...
>Actualy i still have a problem

on this page
http://worldgolfdata.com/Enter/Default.aspx
i have a list of countries when you click on them you get a list of
states, click on a state youi get a list of golf courses from that state.

I have a little bit of test data in it, if you go to Australia, then
select either Victoria or Western Australia you will get a list of 1 or 2
courses repectivly.

I also have a lale that shows what event handler has fired.

if you have a play you will se that when you change state from victoria
to western australia then click on a course the lable shows that the
event handler does not fire till you click the second time.

Can you tell me why and suggets a fix or a workaround?

here is the code

Partial Class Enter_Default
Inherits System.Web.UI.Page

Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
buildCountrys()
If ViewState("buildStates") <"" Then
buildStates()
End If
If ViewState("buildCourses") <"" Then
buildCourses()
End If
End Sub

Sub buildCountrys()
Dim oCountries As Countries
oCountries = New Countries
Dim i As Integer
For i = 0 To UBound(oCountries.getCountries)
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCountry As LinkButton = New LinkButton
AddHandler linkCountry.Click, AddressOf CountryButtClick
linkCountry.OnClientClick = "waitForIt()"
linkCountry.Attributes.Add("class", "dButtons")
linkCountry.CommandArgument = oCountries.getCountries(i).id
linkCountry.Text = oCountries.getCountries(i).Name
td.Controls.Add(linkCountry)
tr.Cells.Add(td)
countryTable.Rows.Add(tr)
Next
End Sub

Sub buildStates()
stateTable.Rows.Clear()
courseTable.Rows.Clear()
Dim oCountry As Country
oCountry = New Country(ViewState("buildStates"))
Dim i As Integer
For i = 0 To UBound(oCountry.getStates)
'On Error Resume Next
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkState As LinkButton = New LinkButton
AddHandler linkState.Click, AddressOf StateButtClick
linkState.OnClientClick = "waitForIt()"
linkState.Attributes.Add("class", "dButtons")
linkState.CommandArgument = oCountry.getStates(i).id
linkState.Text = oCountry.getStates(i).Name
td.Controls.Add(linkState)
tr.Cells.Add(td)
stateTable.Rows.Add(tr)
Next
End Sub

Sub buildCourses()
courseTable.Rows.Clear()
Dim oState As State
oState = New State(ViewState("buildCourses"))
Dim i As Integer
For i = 0 To UBound(oState.getCourses)
If oState.countCourses 0 Then
Dim tr As TableRow = New TableRow
Dim td As TableCell = New TableCell
Dim linkCourse As LinkButton = New LinkButton
AddHandler linkCourse.Click, AddressOf CourseButtClick
linkCourse.OnClientClick = "waitForIt()"
linkCourse.Attributes.Add("class", "dButtons")
linkCourse.CommandArgument = oState.getCourses(i).id
linkCourse.Text = oState.getCourses(i).Name
td.Controls.Add(linkCourse)
courseTable.Rows.Add(tr)
tr.Cells.Add(td)
Else
End If
Next
End Sub

Sub CountryButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildStates", sender.CommandArgument)
Label1.Text = "country clicked"
buildStates()

End Sub

Sub StateButtClick(ByVal sender As Object, ByVal e As EventArgs)
ViewState.Add("buildCourses", sender.CommandArgument)
Label1.Text = "state clicked"
buildCourses()

End Sub

Sub CourseButtClick(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = "course clicked"
End Sub

End Class

"Slim" <me@here.comwrote in message
news:O5**************@TK2MSFTNGP04.phx.gbl...
>>Thanks your example worked fine.
I did try something like this before that made the button persist but
did not add handlers, but all working fine now, thanks allot

"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:OC*************@TK2MSFTNGP04.phx.gbl...
When button2 is clicked, the page postback. At this point button2
doesn't exist any more. You may think that the ViewState takes care of
this, but it only takes care of maintaing values, not actual controls.

You need to re-create button2 on or before the Load event and hook up
it's event handler to have it work. As a matter of fact, you don't even
need to do the AddHandler in the Button1 click, the AddHandler needs to
be done on postback before/during the load event.

One way people often do this is by storing values in the viewstate,
something like:

Button1_Click(...)
dim bt2 as button = new Button()
...
form1.Controls.Add(bt2)
ViewState.Add("LoadButton2", true)
end sub

OnLoad(...)
if Page.IsPostBack then
if not ViewState("LoadButton2") is nothing AndAlso
cbool(ViewState("LoadButton2")) == true then
dim bt2 as button = new Button()
Addhandler bt2.Click ....
Form1.Controls.Add(bt2)
end if
end if
end sub

Denis Bauer has a special PlaceHolderControl that will do all of this
for you. It's free:
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

You should check it out and you might be interested in looking at thee
source code to gain a better fundamental understanding of how it
works...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Slim" <me@here.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl.. .
>i have a simple page, with one button button1.
when click it creates a new button button 2 and adds a event handler
to it.
>
but when button 2 is clicked nothing happens, why?
>
Partial Class test_buttons
>
Inherits System.Web.UI.Page
>
Dim bt2 As Button
>
Dim bt3 As Button
>
Dim test1 As Boolean = False
>
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)
>
Response.Write("Button 1")
>
End Sub
>
Sub bt2Click(ByVal sender As Object, ByVal e As System.EventArgs)
>
If test1 = True Then
>
Response.Write("Button 2")
>
End If
>
End Sub
>
End Class
>
>


Dec 31 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.