Page view counter

Serializing WebControl Properties

Last post 10-20-2004 6:16 PM by adec. 1 replies.

Sort Posts:

  • Serializing WebControl Properties

    10-20-2004, 5:49 PM
    • Loading...
    • fuali
    • Joined on 09-25-2002, 7:31 PM
    • Seattle, WA
    • Posts 14
    • Points 70
    I am creating a custom dropdown control that has a property of an array of SqlParameters. The property makes a neat little dialog to manage and add SqlParameters. But how do I serialize this property. After, using that dialog to add some parameters it inserts the following attribute to the control's tag:

    parameters="SqlParameter[] Array"


    Here's the property code:

    private SqlParameter[] _parameters = new SqlParameter[0];
    
    [ToolboxItem("SqlParameter[]"), Category("DropDown Data"),Description("These are the SqlParameters used by the command.")]
    public SqlParameter[] Parameters
    {
    get
    {
    return _parameters;
    }
    set
    {
    _parameters = value;
    }
    }


    I already have it persisting in the veiwstate by converting them back and forth into a hashtable. but how do I serialize the designer attributes?
  • Re: Serializing WebControl Properties

    10-20-2004, 6:16 PM
    • Loading...
    • adec
    • Joined on 06-15-2002, 2:12 PM
    • Malmoe, Sweden
    • Posts 2,491
    • Points 12,495
    Take a look at the 'DesignerSerializationVisibility' Class. Here is an example:

    protected StyleClass cssStyle = new StyleClass();
    [Browsable(true),
    NotifyParentProperty(true),
    PersistenceMode(PersistenceMode.InnerProperty),
    DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public StyleClass CssStyle
    {
    get
    {
    return this.cssStyle;
    }
    set
    {
    this.cssStyle = value;
    }
    }

    THis article may be of interest to you as well:

    http://www.codeproject.com/aspnet/WebUserControl.asp
    Regards

    Andre Colbiornsen
    ---------------------------------
    Seventh Day
    Råbygatan 1A,
    SE-223 61 Lund
    Sweden
    Mob.: +46-(0)708-97 78 79
    Mail: info@seventhday.se
    --------------------------------
Page 1 of 1 (2 items)