473,739 Members | 4,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CheckedChange d, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls. Add(a)

Dim tRow As New TableRow

tRow.Cells.Add( tCell)

tblTest.Rows.Ad d(tRow)

End Sub

Public Sub ChkboxChecked(B yVal Sender As Object, ByVal e As
System.EventArg s)

'

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 5448
Hi
Try the following:

Private iCounter As Int32 = 0

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) 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.CheckedChange d, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls. Add(a)

Dim tRow As New TableRow

tRow.Cells.Add( tCell)

tblTest.Rows.Ad d(tRow)

End Sub

Public Sub ChkboxChecked(B yVal Sender As Object, ByVal e As
System.EventArg s)

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

"RA" <rc************ ***@storis.com> wrote in message
news:u%******** ********@TK2MSF TNGP15.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.CheckedChange d, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls. Add(a)

Dim tRow As New TableRow

tRow.Cells.Add( tCell)

tblTest.Rows.Ad d(tRow)

End Sub

Public Sub ChkboxChecked(B yVal Sender As Object, ByVal e As
System.EventArg s)

'

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*****@stbern ard.com> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
Hi
Try the following:

Private iCounter As Int32 = 0

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) 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.CheckedChange d, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls. Add(a)

Dim tRow As New TableRow

tRow.Cells.Add( tCell)

tblTest.Rows.Ad d(tRow)

End Sub

Public Sub ChkboxChecked(B yVal Sender As Object, ByVal e As
System.EventArg s)

Dim lsthold As CheckBox = CType(Sender, CheckBox)

Dim a As String

a = "Test"

End Sub

"RA" <rc************ ***@storis.com> wrote in message
news:u%******** ********@TK2MSF TNGP15.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.CheckedChange d, AddressOf ChkboxChecked

Dim tCell As New TableCell

tCell.Controls. Add(a)

Dim tRow As New TableRow

tRow.Cells.Add( tCell)

tblTest.Rows.Ad d(tRow)

End Sub

Public Sub ChkboxChecked(B yVal Sender As Object, ByVal e As
System.EventArg s)

'

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
3673
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.... 2. after population there should be validation in checkboxlist..... that is if user clicks a button wihout checking any one of them(i.e. at least one shuld be checked) ... alerat message shouls come on the form....... these 2 steps should be...
15
4029
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 To intNumBtns - 1 pointLocate.Y += 70
10
5041
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 displayed in the combobox. I have one button on the form to start processing. What I want to do is this: When the user selects the report they want to run from the combobox, I want to dynamically bind the appropriate sub to the button's click...
5
1577
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 completely lost. Below is the essence of the code adding checkbox controls to a panel. (Corresponding to each checkbox is another checkbox and a label.) Do I have to use AddHandler in the loop? Or is there someway outside of a loop to say that a...
2
2211
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 which case the check all checkbox doesn't work at all. The code working with three checkboxes in a group is as follows, but remove two of the three and you will see the code stops working: <script language="javascript"...
2
2412
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 event handler to handle the TextChanged or other appropriate event for all the text boxes (they do not autopostback). When the page posts I want to collect the data in the text boxes and save it to a database. I'm not sure when/where I should...
3
1662
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 private class member (etc. Dim WithEvents mTcp as New MyTCP). Classes/modules; module Main, class MyCtrl and class MyTcp. Any tips why using AddHandler dont work?
5
2206
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 test_buttons Inherits System.Web.UI.Page Dim bt2 As Button
15
2064
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 well as the AddHandler line (I ran a Debug and saw that it executes this code, and the links are displayed on the page afterwards). However, the eventhandler is not called when the LinkButton is clicked. Here is the code that dynamically...
0
9337
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.