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

Handling the events

P: n/a
Hi,
Hi,
I would like to handle the events for the dynamically
created controls at runtime.
I Have written the code in HTML View of an asp.net
page.like this

<script runat="server">
public sub hai(sender as object,e as eventargs)
Dim tr As New TableRow
Dim td1 As New TableCell
Dim Che As New CheckBox
Che.ID = "chkDynamicCheckBox"
Che.Text = "This is a dynamically generated
checkbox"
td1.Controls.Add(Che)
Dim td2 As New TableCell
Dim drop1 As New Button

drop1.Width = New Unit(50)
addhandler button.click,addressof hello
td1.Controls.Add(drop1)
tr.Cells.Add(td1)
tr.Cells.Add(td2)
Table3.Rows.Add(tr)

end sub

public sub hello(ByVal sender As Object, ByVal e As
System.EventArgs)
response.redirect("hello")
end sub

It is giving an error at this point

" addhandler button.click,addressof hello"
My aim is i have created a button drop1 at runtime when i
click this button it should give messge that "Hello"
Any one plz help me.
Regards,
Krishna.
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I *think* this is because you need to reference drop1 and not a button that
does not exist.
Could you post a bit more code as this does not compile due to Table 3(
amongst other things) being missed out

"krishna" <kr***********@nanncomputers.com> wrote in message
news:04****************************@phx.gbl...
Hi,
Hi,
I would like to handle the events for the dynamically
created controls at runtime.
I Have written the code in HTML View of an asp.net
page.like this

<script runat="server">
public sub hai(sender as object,e as eventargs)
Dim tr As New TableRow
Dim td1 As New TableCell
Dim Che As New CheckBox
Che.ID = "chkDynamicCheckBox"
Che.Text = "This is a dynamically generated
checkbox"
td1.Controls.Add(Che)
Dim td2 As New TableCell
Dim drop1 As New Button

drop1.Width = New Unit(50)
addhandler button.click,addressof hello
td1.Controls.Add(drop1)
tr.Cells.Add(td1)
tr.Cells.Add(td2)
Table3.Rows.Add(tr)

end sub

public sub hello(ByVal sender As Object, ByVal e As
System.EventArgs)
response.redirect("hello")
end sub

It is giving an error at this point

" addhandler button.click,addressof hello"
My aim is i have created a button drop1 at runtime when i
click this button it should give messge that "Hello"
Any one plz help me.
Regards,
Krishna.

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.