SkinId and Dynamic Control
Posted
by Alex
on Stack Overflow
See other posts from Stack Overflow
or by Alex
Published on 2010-05-31T12:46:31Z
Indexed on
2010/05/31
12:53 UTC
Read the original article
Hit count: 184
Hi!
I have some control that I add dynamically to my page:
public partial class _Default : Page
{
protected override void CreateChildControls()
{
base.CreateChildControls();
var testControl = new TestControl
{
SkinID = "TestSkin"
};
Controls.Add(testControl);
}
}
I have the following skin file for this control:
<cc:TestControl runat="server" SkinID="TestSkin" TestProperty="LALALA" />
But TestProperty is null (if control is static all works):
public class TestControl : LinkButton
{
public string TestProperty { get; set; }
protected override void OnPreRender(EventArgs e)
{
if (String.IsNullOrEmpty(TestProperty))
{
throw new ArgumentNullException("TestProperty");
}
}
}
Any ideas about how to fix it?
© Stack Overflow or respective owner