Results 1 to 3 of 3

Thread: Web user controls and OO

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    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

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width