-
Web user controls and OO
I have a page where I have the same interface for 8 different attributes (2 listboxes, two buttons, one textbox) I added this
stuff in a user control.
But how can I use that user control form code? How do I reference to it? I have a controller class where I need to loop though each of the user controls and do stuff with the buttons and textboxes
kind regards
Henrik
-
Expose properties and methods of the control as public.
Create a variable that holds a reference to it, and do what you need to with it.
-
I see... so basically I can just drag/drop a usercontrol to my page
make an instance of it
dim myControl as new MyUserControl
and then access it by
myControl.Button1.text = "OK"
The reason is that I want to write a method that takes a usercontrol as in parameter, and fill it's listboxes with data...
Is it possible also to make a "for each" so I can loop though all usercontrols on the page/webform?
And a method that takes the usercontrol and save it's data to a database. Not really sure I should be doing that in the controller, but it is a small enough project.
kind regards
Henrik - a BIG fan of MVC