Hi!
Im trying to make an User Control that acts like a popup and that can be used in several pages.
But I cant figure out how to display the children controls inside the control tag. I want to add all controls to a placeholder. I can add the controls, but they dont render.
This is my control:
[
AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal),
DefaultProperty("Inner"),
ParseChildren(true, "Inner"),
ToolboxData(
"<{0}:Popup runat=\"server\"> </{0}:Popup>")
]
public partial class Popup : Lib.baseControl
{
private List<System.Web.UI.Control> _content;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack && !this.Loaded)
{
foreach(System.Web.UI.Control c in this.Inner) { PlaceHolderContent.Controls.Add(c); }
}
}
public void Show(CommandButton.Types type)
{
string header = string.Empty;
switch (type)
{
case CommandButton.Types.CreateItem:
header = "Legg til ny vare";
break;
case CommandButton.Types.CreateGroup:
header = "Legg til ny gruppe";
break;
}
LiteralHeader.Text = header;
UpdatePanelHeader.Update();
LinkButtonPopupDummy_ModalPopupExtender.Show();
}
private bool Loaded { get { return ViewState["PopupLoaded"] != null ? (bool)ViewState["PopupLoaded"] : false; } set { ViewState["PopupLoaded"] = value; } }
[Category("Behavior"), DefaultValue(""), Description("Inner controls"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public List<System.Web.UI.Control> Inner
{
get
{
if (_content == null) { _content = new List<System.Web.UI.Control>(); }
return _content;
}
}
}
and this is how I want to use it:
<uc1:Popup runat="server" id="PopupCreateItem">
<asp:Image ID="test" runat="server" ImageUrl="https://lctools.lundbeckconsulting.no/Graphic/Public/Icon/dropdown_arrow_black_white.png" />
</uc1:Popup>
Any suggestions?? :)