2013-06-03 30 views
1

我查看網頁代碼:如何在查看頁面呈現後保留0值?

Html.LabelFor(x => x.StartTime, new {@class = ""}), Html.TextBoxFor(x => x.StartTime, new 
            { 
             @class = "startTime form-time", @Value = Model.StartTime.HasValue 
                             ? new DateTime(Model.StartTime.Value.Ticks).ToString("h:mm tt") 
                             : string.Empty 
            }) 

我在TimePicker在開始時間字段使用jQuery slected 08:00 AM。但是在從下拉字段中選擇一個值(進入服務器端)之後,在查看頁面呈現後,時間選擇器字段值更改爲8:00 AM。也就是說,它刪除了值。但我希望價值如同08:00 AM

回答

1

更多信息,它沒有「刪除」的價值 - 它是從來沒有 - 這就像需要使用hh:mm tt而不是h:mm tt

+0

按預期正常工作。謝謝。 –

0

您需要在您的timepicker配置來定義這個喜歡

$('#timepicker').timepicker({ 
    showPeriod: true, 
    showLeadingZero: true 
}); 

你可以找到弗朗索瓦Gelinas頁面上TimePicker

+0

我包含'showLeadingZero:true',但即使'0'值已被刪除。 –