Results 1 to 3 of 3

Thread: User controls and placeholder?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    User controls and placeholder?

    I have a webform where I use 50 different user controls. I have solved the problem with help from DANIEL (thanks again) by adding the user controls to a placeholder. But I have a problem:
    How do I call functions in the the user controls? I receive an error saying:
    Code:
    Object reference not set to an instance of an object
    Everything is working well when I just place the user control on the form, but that is not smart to do when I have 50 controls. So I have checked that there is nothing wrong with the code below as long as the user control is not placed in the placeholder.

    What is wrong?

    Code:
    Dim ctlCond1Abs As Control = LoadControl("Cond1Abs.ascx")
    Dim ctlCond1Black As Control = LoadControl("Cond1Black.ascx")
    
    Sub SetLanguage()
      Page.Controls.Add(ctlCond1Abs)
      plh1.Controls.Add(ctlCond1Abs)
      cond1Abs1.LangArray1 = clsLanguage1.getLanguage(session("language"))
      cond1abs1.setLanguage()
    End Sub

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Re: User controls and placeholder?

    This is an example of a project with some simple code which illustrates my problem.
    Attached Files Attached Files

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: User controls and placeholder?

    I think I just answered this but

    you do a PlaceHolder.FinderControl(id) and cats that control to your user contral class and call the method
    Magiaus

    If I helped give me some points.

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