ASP.net C#引导的DateTimePicker分配值 [英] ASP.net C# bootstrap datetimepicker assign value

查看:101
本文介绍了ASP.net C#引导的DateTimePicker分配值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在引导的DateTimePicker 来显示从code中的日期后面,但它无法正确显示。

I'm trying to display the date from the code behind in the bootstrap DateTimePicker, but it won't display correctly.

这是我的HTML / ASP脚本:

This is my HTML/ASP Script:

<asp:TableCell>
    <asp:Label ID="Label9" runat="server" Text="Label">DATE ISSUED:</asp:Label>
    <div class="form-group">
        <div class='input-group date' id='datetimepicker1'>
            <asp:TextBox ID="txt_DateIssued" runat="server"
                         CssClass="form-control" Width="374px">
            </asp:TextBox>    
            <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
            </span>
        </div>
    </div>                    
</asp:TableCell>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker1').datetimepicker({ format: 'YYYY-MM-DD' });
    });
</script>

这是我的C#code:

And here's my C# code:

txt_DateIssued.Text = "2016-03-13";

输出:
输出 - 的DateTimePicker

当我点击日历图标,在今年开始于0003:(

and when I clicked on the calendar icon, the year begins at 0003 :(

问:
我怎样才能显示在文本框中的日期 2016年3月13日

推荐答案

我假设你正在使用该控件的引导日期选择器的。在未来,你应该包括链接,你有(如果你的问题是关于一个库)的问题库。

I am assuming you are using this control Bootstrap Datepicker. In the future you should include the link to the library you have a question on (if your question is concerning a library).

您的JavaScript看起来不错。你看到在浏览器中任何控制台错误?您是否使用了最新版本?这里是在小提琴工作的code与ASP.NET标签转换为标准的HTML标签。

Your JavaScript looks fine. Are you seeing any console errors in the browser? Are you using the latest version? Here is your code working in a Fiddle with the ASP.NET tags converted to standard HTML tags.

最小HTML片段与脚本标记。

Minimal HTML fragment with script tags.

<div class='container'>
  <div class="form-group">
    <div class='input-group date' id='datetimepicker1'>
      <input type='text' ID="txt_DateIssued" class="form-control" width="374px"></input>    
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>
  </div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>

JavaScript的

JavaScript

$(function () {
   $('#datetimepicker1').datetimepicker({ format: 'YYYY-MM-DD' });
});

这篇关于ASP.net C#引导的DateTimePicker分配值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆