Dynamicly loading a user control

Discussion in 'ASP .Net' started by Ben, May 4, 2004.

  1. Ben

    Ben Guest

    Hi

    I am using this code to dynamically load a user control:

    Dim path As String = "topbar_all.ascx"
    Dim ctl As UserControl = CType(Page.LoadControl(path), UserControl)
    Page.Controls.Add(ctl)

    I get this error when i load the control: "The Controls collection cannot be
    modified because the control contains code blocks (i.e. <% ... %>). "

    But the code does not contain any code blocks.

    Any ideas on the problem?

    THanks B
    Ben, May 4, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henke
    Replies:
    5
    Views:
    654
    Munsifali Rashid
    Dec 30, 2003
  2. Henke
    Replies:
    1
    Views:
    473
  3. Tim
    Replies:
    7
    Views:
    473
    bruce barker
    Oct 29, 2004
  4. MikeM

    Dynamicly loaded User Control events in a Placeholder

    MikeM, Apr 9, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    196
    Jonathan Roberts
    Apr 25, 2004
  5. Mike Housey

    Persistance of Dynamicly added user controls.

    Mike Housey, Aug 5, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    120
    Ken Cox [Microsoft MVP]
    Aug 8, 2003
Loading...

Share This Page