I have a calendar in an aspx page, if the user doesn’t select a date it puts 0001/01/01 into the database. How can I specify another date, like put today’s date instead if no date is chosen?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are couple of ways. If it is the Calendar control, you can programatically set the selected date on Page_Load to Today’s date. That way even if the user doesn’t select a date, you get the default selected date.
Second option would be, before inserting to the database – you can check if the selected date is <=DateTime.MinDate, and set current date in the object.