I am looking for a way, that knowing a controls name, to raise them or call the processes event/code behind.
I am using VB .NET in VS2010
I have an aspx page with a selection of checkboxes in a panel, each checkbox has its own trigger. I have code that saves a list of checked checkboxes. I have code that restores the checked states to those checkboxes, but I need to execute the associated code to the checkboxes checkchanged event.
' Read db to get saved list of checkboxes '
For each result from db
Dim cb As CheckBox
cb = 'a function that finds and returns the control'
' Now that I have the control,
' how can I find and execute it's checkedchanged code?
The control return function is working because in testing, I can process cb.checked = true, and the cb becomes checked, but this doesn’t raise the event/trigger the code.
Example of associated checkedchanged subs:
Protected Sub cb_use_rc3_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cb_use_rc3.CheckedChanged
Protected Sub cb_use_casestatus_CheckedChanged(sender As Object, e As EventArgs) Handles cb_use_casestatus.CheckedChanged
Any ideas?
OK, I’m working on the assumption that your checkboxes each have an individual ID and are not generated by a bound control of any sort.
While it is possible to determine what handler is hooked up to what event of what object (or so I understand), it’s probably more trouble than it’s worth for this limited case.
The simplest, though ugliest, way to do it would be this:
Select Casestatement with the ID of the control to determine which method or methods from #1 to call.