hotwheelharry
06-30-2009, 07:26 PM
I created a custom user control "CustomControl" and I want to reference it in the code behind of a content page.
The reason is because I need to generate a bunch of these custom controls on the content page so i can't include them by doing <tag:CustomControl />.
I need to be able to do
CustomControl myCtrl = new CustomControl();
Page.Controls.Add(myCtrl);
//repeat x times
on the code behind of the content page.
I can't get it to work!
So far I have...
Default settings on content page & on the control.
AND a reference to the control on the content page like...
<%@ Reference Control="~/Controls/CustomControl.ascx" %>
But when I try to create one of these controls in content page code behind it throws an error because it can't find CustomControl.
Sorry about the length of this, I wanted to be thorough.
Any help appreciated! :D
The reason is because I need to generate a bunch of these custom controls on the content page so i can't include them by doing <tag:CustomControl />.
I need to be able to do
CustomControl myCtrl = new CustomControl();
Page.Controls.Add(myCtrl);
//repeat x times
on the code behind of the content page.
I can't get it to work!
So far I have...
Default settings on content page & on the control.
AND a reference to the control on the content page like...
<%@ Reference Control="~/Controls/CustomControl.ascx" %>
But when I try to create one of these controls in content page code behind it throws an error because it can't find CustomControl.
Sorry about the length of this, I wanted to be thorough.
Any help appreciated! :D