Trying to cast a usercontrol using FindControl inside a usercontrol
-
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?
-
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?
I am not sure but I think you need to register the control(contributionEditorControl) to your page.
-
I am not sure but I think you need to register the control(contributionEditorControl) to your page.