Dirty property value persist problem

Discussion in 'ASP .Net Building Controls' started by yp.yean@gmail.com, Aug 24, 2006.

  1. Guest

    Hi,

    I created a custom control, and encountered a dirty property value
    persistence problem.
    I created a property with a custom class type, call SQLSettings which
    holds the SQL connection parameters, the class as follows:


    public sealed class SQLSettings
    {
    private string serverName;
    .......


    public SQLSettings()
    {
    this.serverName = string.Empty;
    ......
    }


    [NotifyParentProperty(true)]
    public string ServerName
    {
    get
    {
    return this.serverName;
    }
    set
    {
    this.serverName = value;
    }
    }
    ...................


    And, I also created an mapping TypeConverter and UITypeEditor classes
    to handle the design-time founctinality. The property I created in my
    conbtrol as follows:


    [BrowsableAttribute(true)]
    [CategoryAttribute("Behavior")]
    [BindableAttribute(true)]
    [NotifyParentProperty(true)]
    [EditorAttribute(typeof(SQLSettingsUITypeEditor),
    typeof(UITypeEditor))]

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

    [TypeConverter((Type)typeof(SQLSettingsTypeConverter))]
    [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    public SQLSettings SQLSettingsData
    {
    get
    {
    return this._sqlSettings;
    }
    set
    {
    this._sqlSettings = value;
    }
    }


    They all works fine when first set value to this property, I can see
    the persisted data showed in .aspx file. When I go back to design view
    and update the property value via my UITypeEditor, I can see the value
    already updated in VS.NET properties browser. But when I turn to see
    ..aspx file in code view, I didn't see the dirty property value updated
    in .aspx file. When I turn to design view, the updated property value
    is lost, it remain keep the first persisted value.


    How to solve this problem? Any idea?
    Thank you for your kindly help.
    , Aug 24, 2006
    #1
    1. Advertising

  2. Teemu Keiski Guest

    As it's complex type, property should be read-only

    ....
    public SQLSettings SQLSettingsData
    {
    get
    {
    if (this._sqlSettings == null)
    this._sqlSettings = new SQLSettings();
    return this._sqlSettings;
    }

    }


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    <> wrote in message
    news:...
    > Hi,
    >
    > I created a custom control, and encountered a dirty property value
    > persistence problem.
    > I created a property with a custom class type, call SQLSettings which
    > holds the SQL connection parameters, the class as follows:
    >
    >
    > public sealed class SQLSettings
    > {
    > private string serverName;
    > .......
    >
    >
    > public SQLSettings()
    > {
    > this.serverName = string.Empty;
    > ......
    > }
    >
    >
    > [NotifyParentProperty(true)]
    > public string ServerName
    > {
    > get
    > {
    > return this.serverName;
    > }
    > set
    > {
    > this.serverName = value;
    > }
    > }
    > ..................
    >
    >
    > And, I also created an mapping TypeConverter and UITypeEditor classes
    > to handle the design-time founctinality. The property I created in my
    > conbtrol as follows:
    >
    >
    > [BrowsableAttribute(true)]
    > [CategoryAttribute("Behavior")]
    > [BindableAttribute(true)]
    > [NotifyParentProperty(true)]
    > [EditorAttribute(typeof(SQLSettingsUITypeEditor),
    > typeof(UITypeEditor))]
    >
    > [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    >
    > [TypeConverter((Type)typeof(SQLSettingsTypeConverter))]
    > [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    > public SQLSettings SQLSettingsData
    > {
    > get
    > {
    > return this._sqlSettings;
    > }
    > set
    > {
    > this._sqlSettings = value;
    > }
    > }
    >
    >
    > They all works fine when first set value to this property, I can see
    > the persisted data showed in .aspx file. When I go back to design view
    > and update the property value via my UITypeEditor, I can see the value
    > already updated in VS.NET properties browser. But when I turn to see
    > .aspx file in code view, I didn't see the dirty property value updated
    > in .aspx file. When I turn to design view, the updated property value
    > is lost, it remain keep the first persisted value.
    >
    >
    > How to solve this problem? Any idea?
    > Thank you for your kindly help.
    >
    Teemu Keiski, Aug 25, 2006
    #2
    1. Advertising

  3. Guest

    Dear Teemu,

    Thank you for your kindly relply. But if the complex type property need
    to be read-only, how can I set the value to it through my UITypeEditor?
    Is there any solution? Thank you.

    Daniel

    Teemu Keiski 寫é“:

    > As it's complex type, property should be read-only
    >
    > ...
    > public SQLSettings SQLSettingsData
    > {
    > get
    > {
    > if (this._sqlSettings == null)
    > this._sqlSettings = new SQLSettings();
    > return this._sqlSettings;
    > }
    >
    > }
    >
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    > <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I created a custom control, and encountered a dirty property value
    > > persistence problem.
    > > I created a property with a custom class type, call SQLSettings which
    > > holds the SQL connection parameters, the class as follows:
    > >
    > >
    > > public sealed class SQLSettings
    > > {
    > > private string serverName;
    > > .......
    > >
    > >
    > > public SQLSettings()
    > > {
    > > this.serverName = string.Empty;
    > > ......
    > > }
    > >
    > >
    > > [NotifyParentProperty(true)]
    > > public string ServerName
    > > {
    > > get
    > > {
    > > return this.serverName;
    > > }
    > > set
    > > {
    > > this.serverName = value;
    > > }
    > > }
    > > ..................
    > >
    > >
    > > And, I also created an mapping TypeConverter and UITypeEditor classes
    > > to handle the design-time founctinality. The property I created in my
    > > conbtrol as follows:
    > >
    > >
    > > [BrowsableAttribute(true)]
    > > [CategoryAttribute("Behavior")]
    > > [BindableAttribute(true)]
    > > [NotifyParentProperty(true)]
    > > [EditorAttribute(typeof(SQLSettingsUITypeEditor),
    > > typeof(UITypeEditor))]
    > >
    > > [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    > >
    > > [TypeConverter((Type)typeof(SQLSettingsTypeConverter))]
    > > [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    > > public SQLSettings SQLSettingsData
    > > {
    > > get
    > > {
    > > return this._sqlSettings;
    > > }
    > > set
    > > {
    > > this._sqlSettings = value;
    > > }
    > > }
    > >
    > >
    > > They all works fine when first set value to this property, I can see
    > > the persisted data showed in .aspx file. When I go back to design view
    > > and update the property value via my UITypeEditor, I can see the value
    > > already updated in VS.NET properties browser. But when I turn to see
    > > .aspx file in code view, I didn't see the dirty property value updated
    > > in .aspx file. When I turn to design view, the updated property value
    > > is lost, it remain keep the first persisted value.
    > >
    > >
    > > How to solve this problem? Any idea?
    > > Thank you for your kindly help.
    > >
    , Aug 26, 2006
    #3
  4. Teemu Keiski Guest

    Note that read-only means that you don't set the reference, you set directly
    its properties.means that in your editor, you don't instantiate new
    SqlSettings, but rather set the properties of the instance returned to you
    by the control. Though this also more from page parsing point of view,
    generic rule is that complex types must be read-only because page parsing
    won't set the instance.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    <> wrote in message
    news:...
    Dear Teemu,

    Thank you for your kindly relply. But if the complex type property need
    to be read-only, how can I set the value to it through my UITypeEditor?
    Is there any solution? Thank you.

    Daniel

    Teemu Keiski ??:

    > As it's complex type, property should be read-only
    >
    > ...
    > public SQLSettings SQLSettingsData
    > {
    > get
    > {
    > if (this._sqlSettings == null)
    > this._sqlSettings = new SQLSettings();
    > return this._sqlSettings;
    > }
    >
    > }
    >
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    > <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I created a custom control, and encountered a dirty property value
    > > persistence problem.
    > > I created a property with a custom class type, call SQLSettings which
    > > holds the SQL connection parameters, the class as follows:
    > >
    > >
    > > public sealed class SQLSettings
    > > {
    > > private string serverName;
    > > .......
    > >
    > >
    > > public SQLSettings()
    > > {
    > > this.serverName = string.Empty;
    > > ......
    > > }
    > >
    > >
    > > [NotifyParentProperty(true)]
    > > public string ServerName
    > > {
    > > get
    > > {
    > > return this.serverName;
    > > }
    > > set
    > > {
    > > this.serverName = value;
    > > }
    > > }
    > > ..................
    > >
    > >
    > > And, I also created an mapping TypeConverter and UITypeEditor classes
    > > to handle the design-time founctinality. The property I created in my
    > > conbtrol as follows:
    > >
    > >
    > > [BrowsableAttribute(true)]
    > > [CategoryAttribute("Behavior")]
    > > [BindableAttribute(true)]
    > > [NotifyParentProperty(true)]
    > > [EditorAttribute(typeof(SQLSettingsUITypeEditor),
    > > typeof(UITypeEditor))]
    > >
    > > [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    > >
    > > [TypeConverter((Type)typeof(SQLSettingsTypeConverter))]
    > > [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
    > > public SQLSettings SQLSettingsData
    > > {
    > > get
    > > {
    > > return this._sqlSettings;
    > > }
    > > set
    > > {
    > > this._sqlSettings = value;
    > > }
    > > }
    > >
    > >
    > > They all works fine when first set value to this property, I can see
    > > the persisted data showed in .aspx file. When I go back to design view
    > > and update the property value via my UITypeEditor, I can see the value
    > > already updated in VS.NET properties browser. But when I turn to see
    > > .aspx file in code view, I didn't see the dirty property value updated
    > > in .aspx file. When I turn to design view, the updated property value
    > > is lost, it remain keep the first persisted value.
    > >
    > >
    > > How to solve this problem? Any idea?
    > > Thank you for your kindly help.
    > >
    Teemu Keiski, Aug 26, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Umut Tezduyar
    Replies:
    0
    Views:
    420
    Umut Tezduyar
    Nov 29, 2005
  2. Replies:
    3
    Views:
    1,633
    Bruce Barker
    Mar 20, 2006
  3. Replies:
    0
    Views:
    340
  4. bussiere bussiere

    Re: [Pickle]dirty problem 3 lines

    bussiere bussiere, Sep 1, 2010, in forum: Python
    Replies:
    2
    Views:
    337
    bussiere bussiere
    Sep 2, 2010
  5. Dirty property value persist problem

    , Aug 24, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    125
Loading...

Share This Page