473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AddHandler for CheckBox is not working

RA
I have simpe code as follows.

Private sub Page_load.....
FillTable()
End Sub

Private Sub FillTable()

'

Dim a As New CheckBox

a.ID = "chkTest"

AddHandler a.CheckedChanged, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls.Add(a)

Dim tRow As New TableRow

tRow.Cells.Add(tCell)

tblTest.Rows.Add(tRow)

End Sub

Public Sub ChkboxChecked(ByVal Sender As Object, ByVal e As
System.EventArgs)

'

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

I have breakpoint in ChkboxChecked procedure and it never gets hit.


Nov 18 '05 #1
2 5428
Hi
Try the following:

Private iCounter As Int32 = 0

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim i As Int32

For i = 0 To 10

FillTable()

Next

End Sub

Private Sub FillTable()

Dim a As New CheckBox

iCounter += 1

a.ID = "chkTest" + CStr(iCounter)

a.AutoPostBack = True

AddHandler a.CheckedChanged, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls.Add(a)

Dim tRow As New TableRow

tRow.Cells.Add(tCell)

tblTest.Rows.Add(tRow)

End Sub

Public Sub ChkboxChecked(ByVal Sender As Object, ByVal e As
System.EventArgs)

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

"RA" <rc***************@storis.com> wrote in message
news:u%****************@TK2MSFTNGP15.phx.gbl...
I have simpe code as follows.

Private sub Page_load.....
FillTable()
End Sub

Private Sub FillTable()

'

Dim a As New CheckBox

a.ID = "chkTest"

AddHandler a.CheckedChanged, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls.Add(a)

Dim tRow As New TableRow

tRow.Cells.Add(tCell)

tblTest.Rows.Add(tRow)

End Sub

Public Sub ChkboxChecked(ByVal Sender As Object, ByVal e As
System.EventArgs)

'

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

I have breakpoint in ChkboxChecked procedure and it never gets hit.

Nov 18 '05 #2
RA
Thank you for your help.

I was not setting AutoPostBack to True and that was the reason it was not
hitting the breakpoint.

"Yama" <yk*****@stbernard.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
Hi
Try the following:

Private iCounter As Int32 = 0

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim i As Int32

For i = 0 To 10

FillTable()

Next

End Sub

Private Sub FillTable()

Dim a As New CheckBox

iCounter += 1

a.ID = "chkTest" + CStr(iCounter)

a.AutoPostBack = True

AddHandler a.CheckedChanged, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls.Add(a)

Dim tRow As New TableRow

tRow.Cells.Add(tCell)

tblTest.Rows.Add(tRow)

End Sub

Public Sub ChkboxChecked(ByVal Sender As Object, ByVal e As
System.EventArgs)

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

"RA" <rc***************@storis.com> wrote in message
news:u%****************@TK2MSFTNGP15.phx.gbl...
I have simpe code as follows.

Private sub Page_load.....
FillTable()
End Sub

Private Sub FillTable()

'

Dim a As New CheckBox

a.ID = "chkTest"

AddHandler a.CheckedChanged, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls.Add(a)

Dim tRow As New TableRow

tRow.Cells.Add(tCell)

tblTest.Rows.Add(tRow)

End Sub

Public Sub ChkboxChecked(ByVal Sender As Object, ByVal e As
System.EventArgs)

'

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

I have breakpoint in ChkboxChecked procedure and it never gets hit.


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
15
by: Paul Mars | last post by:
I am creating a user selectable quantity of buttons at run time and need to respond to their click events. My code: Dim btnButton as Button (global) Then in a sub: For intNumBtnsDown = 0...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
5
by: eBob.com | last post by:
I've used AddHandler for a UNIQUE control added to a panel and it seemed to work. But now I want to add a bunch of controls to a panel and use only one event handler subroutine. And I am...
2
by: limbo2u | last post by:
I'm using the following code for a checkbox that when clicked, either checks or unchecks a group of checkboxes on a form. The code works fine, except when there is only one checkbox in the group in...
2
by: bill | last post by:
I am building a web form dynamically using VB 2005. I add several textbox controls, radio button controls, checkbox list controls, etc. to a placehoder control on the page, and I want to add an...
3
by: Vemund Halvorsen | last post by:
Hi, Im having some trouble getting Addhandler to work. Using withevents everything is working fine. But with AddHandler I get no callback. The code below works fin if I declare _tcp as a...
5
by: Slim | last post by:
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...
15
by: Nathan Sokalski | last post by:
I have a section of my code that dynamically creates LinkButtons to allow the user to go to the page containing a question they have not answered. The code that creates the LinkButton is called, as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.