5

शीर्षक के रूप में मेरी समस्या है, यह है कि मुझे अमेक्स कंट्रोलटूलकिट से मास्केड एडिट एक्स्टेंडर द्वारा दिनांकित दिनांकों के लिए वर्ष के साथ छोटे महीने के नाम प्रारूप का उपयोग करने की आवश्यकता है। डेटटाइम के लिए एमएमएम-वाईय मास्केडएडिट एक्स्टेंडर.मास्क = "एलएलएल 99 99" जैसा नहीं है।क्या मास्केड एडिट एक्स्टेंडर के लिए मास्क सेट करना संभव है कि प्रारूप प्रारूप MMM-yyyy जो किसी भी संस्कृति में काम करेगा?

यदि मैं एन-यूएस लोकेल का उपयोग करता हूं, तो यह चीज़ आकर्षक की तरह काम करती है, लेकिन अगर मैं फ्रैंक-एफआर पर स्विच करता हूं तो यह काम नहीं करेगा क्योंकि फ्रेंच में लघु महीने का प्रतिनिधित्व 4 से 5 अक्षरों (डॉट समेत) के बीच उपयोग करता है।

इस पर कोई विचार? धन्यवाद।

उत्तर

0

क्या आप इस तरह कुछ उपयोग करके मास्क गतिशील रूप से सेट कर सकते हैं?

string shortDateFormat = 
    System.Globalization.CultureInfo.DateTimeFormat.ShortDatePattern 
+0

से पहले की कोशिश की है कि, लेकिन नहीं, क्योंकि प्रारूप इसे इस्तेमाल करता है उन पैटर्न से अलग है। –

1
 
Here you need to define the mask and mask type explicitly instead of declaring in the control itself. 

Follow the steps 

1. Create a method to get n set mask 


public string Mask 
     { 
      get 
      { 
       return GetPropertyValue("Mask", ""); 
      } 
      set 
      { 

       SetPropertyValue("Mask", value); 
      } 
     } 



2. Create a method to get n set mask type 

    public MaskedEditType MaskType 
     { 
      get 
      { 
       return GetPropertyValue("MaskType", MaskedEditType.None); 
      } 
      set 
      { 
       SetPropertyValue("MaskType", value); 

       AcceptAMPM = false; 
       AcceptNegative = MaskedEditShowSymbol.None; 
       DisplayMoney = MaskedEditShowSymbol.None; 
       InputDirection = MaskedEditInputDirection.LeftToRight; 
       break; 


      } 
     } 


3. Create a method to get the culture and culture date format 



public string CultureName 
     { 
      get 
      { 
       return GetPropertyValue("Culture", ""); 
      } 
      set 
      { 
       try 
       { 
        if (!String.IsNullOrEmpty(value)) 
        { 
         System.Globalization.CultureInfo CultControl = System.Globalization.CultureInfo.GetCultureInfo(value); 
         SetPropertyValue("Culture", CultControl.Name); 
         CultureDatePlaceholder = CultControl.DateTimeFormat.DateSeparator; 

         char sep = System.Char.Parse(CultControl.DateTimeFormat.DateSeparator); 
         string[] arrDate = CultControl.DateTimeFormat.ShortDatePattern.Split(sep); 
         string ret = arrDate[0].Substring(0, 1).ToUpper(CultControl); 
         ret += arrDate[1].Substring(0, 1).ToUpper(CultControl); 
         ret += arrDate[2].Substring(0, 1).ToUpper(CultControl); 
         CultureDateFormat = ret; 


        } 
        else 
        { 
         SetPropertyValue("Culture", ""); 
         CultureDatePlaceholder = ""; 

        } 
       } 
       catch 
       { 
        throw new ArgumentException("The Culture is invalid!"); 
       } 
      } 
     } 


4. Create a method to get the culture date format 



public string CultureDateFormat 
     { 
      get 
      { 
       return GetPropertyValue("CultureDateFormat", ""); 
      } 
      set 
      { 
       SetPropertyValue("CultureDateFormat", value); 
      } 
     } 


5. Now load the value on pre render 



protected override void OnPreRender(EventArgs e) 

     { 
      base.OnPreRender(e); 
      switch (MaskType) 
      { 
       case MaskedEditType.Date: 
        { 
         AcceptAMPM = false; 
         AcceptNegative = MaskedEditShowSymbol.None; 
         DisplayMoney = MaskedEditShowSymbol.None; 
         InputDirection = MaskedEditInputDirection.LeftToRight; 
         break; 
        } 

      } 
      System.Globalization.CultureInfo CultControl = System.Globalization.CultureInfo.CurrentCulture; 
      if (!String.IsNullOrEmpty(CultureName)) 
      { 
       CultControl = System.Globalization.CultureInfo.GetCultureInfo(CultureName); 
      } 
      CultureDatePlaceholder = CultControl.DateTimeFormat.DateSeparator; 

      char sep = System.Char.Parse(CultControl.DateTimeFormat.DateSeparator); 
      string[] arrDate = CultControl.DateTimeFormat.ShortDatePattern.Split(sep); 
      string ret = arrDate[0].Substring(0, 1).ToUpper(CultControl); 
      ret += arrDate[1].Substring(0, 1).ToUpper(CultControl); 
      ret += arrDate[2].Substring(0, 1).ToUpper(CultControl); 
      CultureDateFormat = ret; 

     } 


6. Last create a function to validate the user input 

    private bool validateMaskType() 
      { 
       string mask = Mask; 
       MaskedEditType maskType = MaskType; 
       if (!string.IsNullOrEmpty(mask) && (maskType == MaskedEditType.Date)) 
       { 
        string validMask = MaskedEditCommon.GetValidMask(mask); 
        switch (maskType) 
        { 
         case MaskedEditType.Date: 
          return Array.IndexOf(new string[] { "99/99/9999", "99/9999/99", "9999/99/99", "99/99/99" }, validMask) >= 0; 

          break; 
        } 
       } 
       return true; 
      }