Dirty property value persist problem

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Dirty property value persist problem

    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(DesignerSerializat ionVisibility.Content)]

    [TypeConverter((Type)typeof(SQLSettingsTypeConverte r))]
    [PersistenceModeAttribute(PersistenceMode.InnerProp erty)]
    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.

    yp.yean@gmail.com Guest

  2. Similar Questions and Discussions

    1. Property Inspector for Locked Content Doesn't SetContent Dirty
      I have a property inspector for my locked content. When the user sets a new value in the inspector, the orig attribute of the MM:BeginLock tag is...
    2. Control Designer change property but does not persist
      Hi All, I'm developing a custom control for ASP.NET (2.0 but this shouldn't matter). I've got a property PageID (Guid) in this control: ...
    3. WebControl Design View Persist Problem
      I'm having some weird things happen in design view while editing a custom collection - I've been at this for about 4 weeks now, and have tried all...
    4. Shakira getting dirty with dildo
      > Shakira spreading on bed with dildo I'd like to meet shakira. But let's keep it to on-topic newsgroups like alt.porn and comp.idiots
    5. help: shockwave dirty shadow!
      Hi, I made a small scene in 3DStudioMax, without any lights. Rendering in Max is OK, but when I export to Shockwave3D, I get a dirty shadow on...
  3. #2

    Default Re: Dirty property value persist problem

    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
    [url]http://blogs.aspadvice.com/joteke[/url]


    <yp.yean@gmail.com> wrote in message
    news:1156393251.472673.191100@i3g2000cwc.googlegro ups.com...
    > 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(DesignerSerializat ionVisibility.Content)]
    >
    > [TypeConverter((Type)typeof(SQLSettingsTypeConverte r))]
    > [PersistenceModeAttribute(PersistenceMode.InnerProp erty)]
    > 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 Guest

  4. #3

    Default Re: Dirty property value persist problem

    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
    > [url]http://blogs.aspadvice.com/joteke[/url]
    >
    >
    > <yp.yean@gmail.com> wrote in message
    > news:1156393251.472673.191100@i3g2000cwc.googlegro ups.com...
    > > 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(DesignerSerializat ionVisibility.Content)]
    > >
    > > [TypeConverter((Type)typeof(SQLSettingsTypeConverte r))]
    > > [PersistenceModeAttribute(PersistenceMode.InnerProp erty)]
    > > 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.
    > >
    yp.yean@gmail.com Guest

  5. #4

    Default Re: Dirty property value persist problem

    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
    [url]http://blogs.aspadvice.com/joteke[/url]

    <yp.yean@gmail.com> wrote in message
    news:1156555051.134775.112870@74g2000cwt.googlegro ups.com...
    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
    > [url]http://blogs.aspadvice.com/joteke[/url]
    >
    >
    > <yp.yean@gmail.com> wrote in message
    > news:1156393251.472673.191100@i3g2000cwc.googlegro ups.com...
    > > 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(DesignerSerializat ionVisibility.Content)]
    > >
    > > [TypeConverter((Type)typeof(SQLSettingsTypeConverte r))]
    > > [PersistenceModeAttribute(PersistenceMode.InnerProp erty)]
    > > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139