How do you stop the designer from auto generating code that sets the value for public properties on a user control?
How do you stop the designer from auto generating code that sets the value for public properties on a user control?
Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Name
{
get;
set;
}
Add the following attributes to the property in your control:
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
A slight change to Erik's answer I am using VS 2013.
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new string Name {
get;
set;
}