<asp:TextBox ID="txtStartDateTime" runat="server"></asp:TextBox> <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" TargetControlID="txtStartDateTime" runat="server" Mask="99/99/9999 99:99" MessageValidatorTip="true" MaskType="DateTime" ClearMaskOnLostFocus="true" ClearTextOnInvalid="true" AcceptAMPM="true" UserDateFormat="DayMonthYear" ErrorTooltipEnabled="True"> </ajaxToolkit:MaskedEditExtender> <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="txtStartDateTime" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input Date and Time" InvalidValueMessage="Date Time Input Not Valid"> </ajaxToolkit:MaskedEditValidator>
string strStartDateTime = txtStartDateTime.Text; DateTime dtStartingDateTime = new DateTime(); dtStartingDateTime = DateTime.ParseExact(strStartDateTime, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style) at System.DateTime.ParseExact(String s, String format, IFormatProvider provider)
strStartDateTime
DateTime.ParseExact
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)