一个有 txtDateReceived,第二个有 txtVendorPackDate。在插入将添加记录之前,我必须检查 txtDateReceived 是否比 txtVendorPackDate 更准确。我尝试使用 TextChanged 事件。
protected void txtVendorPackDate_TextChanged(object sender, EventArgs e)
{
DateTime fromDate = DateTime.MinValue;
DateTime toDate = DateTime.MaxValue;
bool parseResultMin = DateTime.TryParse(txtVendorPackDate.Text, out fromDate);
bool parseResultMax = DateTime.TryParse(txtDateReceived.Text, out toDate);
if (toDate < fromDate)
{
txtVendorPackDate.Text = "";
lblDateExpired.Visible = true;
lblDateExpired.Text = "Selected date is incorrect, please enter correct data.";
txtVendorFatPerc.Focus();
}
double expired = toDate.Subtract(fromDate).TotalDays;
if (expired >= 60)
{
lblDateExpired.Text = "Date Expired " + expired + " days after pack day!!!"
lblDateExpired.Visible = true;
}
}
我如何从客户端不使用控件验证来做到这一点。