Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. cannot detect User Control

cannot detect User Control

Scheduled Pinned Locked Moved ASP.NET
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sameercodes
    wrote on last edited by
    #1

    Hi people, this is very very urgent. please help. I have a user control which is being loaded dynamically. This user control is being placed ina place holder. The code is as follows:

    UserControl ucUserControl = (UserControl)Page.LoadControl("../AM/UserControls/ucMyUserControl.ascx");

    ucUserControl.ID = "userControl_ID";

    phPlaceHolder.Controls.Add(ucUserControl);

    Now, I am trying to access the user control by using FindControl:

    UserControl ucUserControl = (UserControl)phPlaceHolder.FindControl("userControl_ID");

    The problem is the user control is not detected. That is, ucUserControl = null Please help guys. Thanks.

    S 1 Reply Last reply
    0
    • S sameercodes

      Hi people, this is very very urgent. please help. I have a user control which is being loaded dynamically. This user control is being placed ina place holder. The code is as follows:

      UserControl ucUserControl = (UserControl)Page.LoadControl("../AM/UserControls/ucMyUserControl.ascx");

      ucUserControl.ID = "userControl_ID";

      phPlaceHolder.Controls.Add(ucUserControl);

      Now, I am trying to access the user control by using FindControl:

      UserControl ucUserControl = (UserControl)phPlaceHolder.FindControl("userControl_ID");

      The problem is the user control is not detected. That is, ucUserControl = null Please help guys. Thanks.

      S Offline
      S Offline
      Spunky Coder
      wrote on last edited by
      #2

      Use the following in your aspx page... <%@ Reference Control="../AM/UserControls/ucMyUserControl.ascx" %>

      "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups