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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Trying to cast a usercontrol using FindControl inside a usercontrol

Trying to cast a usercontrol using FindControl inside a usercontrol

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettestingbeta-testinghelp
3 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.
  • T Offline
    T Offline
    totig
    wrote on last edited by
    #1

    Hi I was running my application just fine, but when it came to trying to precompile the application, I got an error saying "the type or namespace name 'x' could not be found. What I have is few pages, and a folder called usercontrols with a few controls(ascx) inside it. What I do is load both controls on a page, and inside the one control I use the FindControl method, and attempt to cast it to the control type (as I said, this was working perfectly during my testing), and then set a few properties of the control. Now I do the same thing on one of my pages, and it works fine. This is the line of code i use: usercontrols_ContributionEditorControl contribCtrl = (usercontrols_ContributionEditorControl)Page.FindControl("contributionEditorControl"); Is there a way I can force asp.net to see that I have all these controls in the controls directory? I dont even mind if its possible to turn this warning off (though I would rather get it fixed), but I do need it to work this way. Or is there another way to set the controls properties from within a control?

    B 1 Reply Last reply
    0
    • T totig

      Hi I was running my application just fine, but when it came to trying to precompile the application, I got an error saying "the type or namespace name 'x' could not be found. What I have is few pages, and a folder called usercontrols with a few controls(ascx) inside it. What I do is load both controls on a page, and inside the one control I use the FindControl method, and attempt to cast it to the control type (as I said, this was working perfectly during my testing), and then set a few properties of the control. Now I do the same thing on one of my pages, and it works fine. This is the line of code i use: usercontrols_ContributionEditorControl contribCtrl = (usercontrols_ContributionEditorControl)Page.FindControl("contributionEditorControl"); Is there a way I can force asp.net to see that I have all these controls in the controls directory? I dont even mind if its possible to turn this warning off (though I would rather get it fixed), but I do need it to work this way. Or is there another way to set the controls properties from within a control?

      B Offline
      B Offline
      Bassam Saoud
      wrote on last edited by
      #2

      I am not sure but I think you need to register the control(contributionEditorControl) to your page.

      T 1 Reply Last reply
      0
      • B Bassam Saoud

        I am not sure but I think you need to register the control(contributionEditorControl) to your page.

        T Offline
        T Offline
        totig
        wrote on last edited by
        #3

        Hi, thanks for the advice. I will try this and see what happens - I had registered the controls in the web.config file, but I will try put it onto the page and see what happens.

        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