C# DateTimePicker
-
I am new to C#, but am trying to write a small windows application that will write execuatable cmd line code to a Batch File, and then run the Batch File. I can stop a user from entering a date prior to the Max and before the Min allowable. However, during testing I found that I am able to type in an invalid year or a day AFTER valid dates have been chosen, and these invalid values will be the actual values written to the Batch File. How do I force the user to only select dates from the dropdown monthly calendar and not change those valid dates manualy once picked? Thanks for any help.:(( AlEvangePA
-
I am new to C#, but am trying to write a small windows application that will write execuatable cmd line code to a Batch File, and then run the Batch File. I can stop a user from entering a date prior to the Max and before the Min allowable. However, during testing I found that I am able to type in an invalid year or a day AFTER valid dates have been chosen, and these invalid values will be the actual values written to the Batch File. How do I force the user to only select dates from the dropdown monthly calendar and not change those valid dates manualy once picked? Thanks for any help.:(( AlEvangePA
I would suggest validating the date they entered / selected in the code behind. That way you will know for sure the date is valid. Best options for validating date: TryParse Or Try { Datetime dt = Convert.ToDateTime(Dropdownlist.selectedValue); } catch { MessageBox.Show("Please enter a valid date."); return; } Anyway, that would be my suggestion. Hope that helps. Ben