asp.net - UserControl Default Value in Property -
I have a user control with some boolean properties. I would like to set them by default if I have not explicitly set them in .aspx page, or at least force them to declare if there is no way to set default I know that such a One way to do this is because many controls require your app to break, when you try to run it and they are not declared.
How can I do this?
Example:
& lt; Je: myControl runat = "server" id = "myControl" showBox = "False" & gt; I want to either break the system or set the default to "true" if the ShowBox stays out of this announcement.
Thank you!
Define your properties with their default values like:
Private bool _ShowBox = false; Public Bull Showbox {Set {_ShowBox = value; }} Or in the manufacturer of your control, set the default value:
Public MyControl () {_ShowBox = false; } Or assign it if it is not assigned:
private bool _ShowBox = false; Public Bull Showbox {Set {_ShowBox = value; } {Return _ShowBox; }}
Comments
Post a Comment