从 asp 文本框中删除 00:00:00

Remove 00:00:00 from the asp Textbox

我有一个文本框,我在其中使用 DatePicker 约会并保存它。当我再次检查文本框中的日期时,值在

02-04-1996 00:00:00

我想删除

00:00:00

看看图片

怎么做?请帮忙

更新代码

日期选择器的 JS 代码:-

$(function () {
        $("[id$=mainContent_txtdateofbirth], [id$=mainContent_txtdoj], [id$=mainContent_txtdol]").datepicker({
            textboxImageOnly: true,
            textboxImage: 'images/calendar.png',
            changeMonth: true,
            changeYear: true,
            dateFormat: "{0:DD-MM-YY}",
            yearRange: "-40:+0",
            maxDate: new Date(),
        });
    });

尝试按以下顺序排列日期:

"0:DD-MM-YY"

这行得通!

change the date-picker control property to custom.

DateTimePicker1.Format = DateTimePickerFormat.Custom;
DateTimePicker1.CustomFormat = "dd-MM-yyyy";

参见 Here DateTimePicker.CustomFormat 属性

编辑 2:

if you are using jQuery date picker.change the datepicker date format property.

尝试

var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();

here 1 and here 2有一些参考,你可以看看。

像下面这样试过并且有效:-

codebehind

txtdateofbirth.Text = DateTime.Parse(dt.Rows[0]["dob"].ToString()).ToShortDateString();

ToShortDateString(); 从文本框中删除了 00:00:00