views:

124

answers:

1

I'm testing a simple User Control in Visual Studio 2008: A Panel named Wrapper with some controls inside. Can Visual Studio handle this at design time?

public partial class TestControl : System.Web.UI.UserControl
{
    [Description("Css class of the div around the control.")]
    [CssClassProperty]
    public string CssClass
    {
        get { return Wrapper.CssClass; }
        set { Wrapper.CssClass = value; }
    }
}

When setting the CssClass property, it doesn't update the css of the Panel at design time. Am I hoping for too much?

A: 

I think you would have to check the parent and cast it

if(this.Parent is Panel) { ((Panel)this.Parent).CssClass = value; }

Or similar.

phil