473,698 Members | 2,630 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 5444
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
3671
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
4026
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
5038
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
1572
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
2209
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
2411
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
1660
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
2203
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
2060
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
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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
8901
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
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
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...
0
5862
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
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.