Live Chat Icon For mobile
Live Chat Icon

ASP.NET FAQ - Serialization

Find answers for the most frequently asked questions
Expand All Collapse All

Some common mistakes that will cause the designer to choke while persisting collection properties are:

  • The corresponding collection type cannot have multiple (overloaded) indexers. You should always define a single indexer of the type ‘public SomeType this[object obj]{…}‘. Otherwise the changes will be persisted but the control will not load in the designer. You will see a ‘Ambiguous match found’ error.
  • If the collection property has the PersistenceMode attribute set to InnerProperty then the property should not include a set method.
  • Permalink

    Nested properties in your controls should be marked with the NotifyParentProperty(true) attribute in order for the designer to get notified that it’s value has changed.

    For example, the following property (SubProperty) declaration should include the above mentioned attribute, for the designer to persist changes to that property during design-time:

    myControl.SomeComplexProperty.SubProperty = 'some value';

    All string type properties get saved as attributes of the parent tag inspite of the InnerProperty attribute setting. In fact, setting the InnerProperty attribute might prevent the property from getting saved at all.

    For example, in the property declaration below:

    PersistenceMode(PersistenceMode.Attribute), // This should always be Attribute, not anything else like InnerProperty.
    public string Text{get{return text;}set{text = value;}}

    Share with

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.