c# - Custom Property of a Custom User Control gets reset during rebuild -


i have following properties

[defaultvalue(true), category("behavior")] public bool enablebinding { get; set; }          [defaultvalue(false), category("behavior")] public bool needapprove { get; set; } 

when changed using designer , save rebuild, new values set through designer remain property needapprove. enablebinding getting reset false.

tried

1) designerserializationvisibility attributes, didnt work!

  • visible
  • hidden
  • content

2) converting auto property full property worked. why? can not achieve without converting full property?

you should assign initial value enablebinding property within custom user-control constructor:

public partial class customusercontrol : usercontrol {     public customusercontrol() {         initializecomponent();         enablebinding = true; // !!!     }     [defaultvalue(true), category("behavior")]     public bool enablebinding { get; set; }     [defaultvalue(false), category("behavior")]     public bool needapprove { get; set; } } 

without initialized false during deserialization.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -