UserControl C # Custom Properties

I create a usercontrol that provides all the general checks for a range of styles of text fields: alpha, number, decimal, SSN, etc., so when the developer using this control selects the alpha style, they can also choose another property. which defines a string of special characters that can also be resolved during validation.

but when a decimal style is selected, for example, I would just like to turn off the special character property so that it does not set when a style is selected that does not allow the use of special characters.

How can I achieve this?

thank

+3
source share
2 answers

# - , promises, .

- , . .NET - , . CompareValidator, :

ControlToCompare ValueToCompare . . set, ControlToCompare .

, , - , . : .

, . , , - .

+2

private string specialCharacters = "";
public string SpecialCharacters
{
   get { if ( usingDecimals ) 
           specialCharacters = "";

        return specialCharacters; }

   set { if( usingDecimals )
            value = "";

         specialCharacters = value; }
}

private boolean usingDecimals = false;
public boolean UsingDecimals
{  get { return usingDecimals; } 
   set { usingDecimals = value;
         if( usingDecimals )
             specialCharacters = ""; }
}
0

Source: https://habr.com/ru/post/1742989/


All Articles