Addhandler with Static Items

D

Dave H

I've used AddHandler to add event handling to dynamically create AspX
controls, but I'm having issues assigned a group of static controls the same
way.

This is the code I'm trying:

For nIndex = 1 To nNumberofControls
Try
oCheckBox = FindControl("CheckBox" & nIndex)
oCheckBox.AutoPostBack = True
AddHandler oCheckBox.CheckedChanged, AddressOf HandleProductCheck
Catch ex As Exception
'
End Try
Next

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

What am I missing?

Thanks...
 
T

Teme64

Dave said:
I've used AddHandler to add event handling to dynamically create AspX
controls, but I'm having issues assigned a group of static controls the same
way.

This is the code I'm trying:

For nIndex = 1 To nNumberofControls
Try
oCheckBox = FindControl("CheckBox" & nIndex)
oCheckBox.AutoPostBack = True
AddHandler oCheckBox.CheckedChanged, AddressOf HandleProductCheck
Catch ex As Exception
'
End Try
Next

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

What am I missing?

Thanks...
I'm not familiar with web controls, but your code seems ok to me.

There's one thing to point out which happens at least with WinForms
controls. After you have added your own CheckedChanged event's handler
and if you have already a CheckedChanged event handler, the first
event handler gets called first and only after that your
HandleProductCheck gets called.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top