0

私はいくつかのブートストラップ日時ピッカーを持っており、DBから読み取られたデータを使用して、サーバーからテキストボックスと選択日時を設定しようとしています。今日の午前12時に設定されています。ブートストラップdatetimepicker - 日付時刻サーバー側を設定

$(document).ready(function() { 
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
    Sys.WebForms.PageRequestManager.getInstance().beginAsyncPostBack(); 
    function EndRequestHandler(sender, args) { 
     $('#tpStartDate').datetimepicker({ 
      sideBySide: true, 
      ignoreReadonly:true, 
      daysOfWeekDisabled:[0,6] 
     }); 
     $('#tpEndDate').datetimepicker({ 
      sideBySide: true, 
      ignoreReadonly:true, 
      daysOfWeekDisabled:[0,6] 
     }); 
    } 
}); 
<div class="col-sm-3 col-md-3"> 
    <div class="form-group"> 
     <label for="title">Start Date</label> 
     <div class="input-group date" id="tpStartDate"> 
      <input runat="server" id="tbStartDateTime" type="text" class="form-control" readonly="readonly" style="cursor:pointer" /> 
      <span class="input-group-addon"> 
       <span class="glyphicon glyphicon-calendar" style="cursor:pointer"></span> 
      </span> 
     </div> 
    </div> 
</div> 

は.cs:

これは上記のための私の.aspxと.aaspx.csファイルの内容である私は、上記のブレークポイントを置くとき、私は日時を開始参照

tbStartDateTime.Value = dtClassList.Rows[0]["StartDateTime"].ToString(); 
tbEndDateTime.Value = dtClassList.Rows[0]["EndDateTime"].ToString(); 

があります」 10/17/2017 12:00 AM "と表示されていますが、このページでは、両方とも" 10/17/2017 12:00 AM "と表示されています。 (今日の日付)

答えて

0

これには、オプションとしてuseCurrent: falseを設定する必要がありますデフォルトではuseCurrentがtrueです。

設定しないと、ページ上の現在の日付と時刻のピッカーが常に起動します。

しかし、彼らは両方とも「2017年10月17日午前12時00分」 (今日の日付)として表示されているページの

これは、古いバグです:https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1311

これでした最新バージョンで解決しました。私はあなたに助言します。V 4.17.47

+0

私は4.14.30バージョンです。私は4.17.47を試してみましたが、スタイルを乱してしまいました。おそらく、Bootstrap 3.3.7でうまくいきません。しかし、useCurrent:falseを設定すると、私の問題が解決されたようです。ありがとう。 – NoBullMan

+0

BS 3.3.7を使用しているので、CSSのスタイル(ライブラリのもの)をバージョンバンプで更新することを忘れないでください。 –

関連する問題