0

我想使用 datetimepicker 但它给出了错误:

TypeError: Object # has no method 'datetimepicker'

我包括了这个脚本:

<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-timepicker-addon.js" type="text/javascript"></script>

还有我的代码:

   TextBox dtPicker_ = new TextBox();
   dtPicker_.ID = "dt_" + i;
   dtPicker_.CssClass = "datePicker";
   dtPicker_.Attributes.Add("checkId", "ch_" + i);

   dtPicker_.Text = cell_value_format_.Trim();
   control_ = dtPicker_;


  // ConvertToTimePicker
  string csname1 = "BindDatePickerScript";
  Type cstype = this.GetType();

  // Get a ClientScriptManager reference from the Page class.
  ClientScriptManager cs = Page.ClientScript;
  // Check to see if the startup script is already registered.
  if (!cs.IsStartupScriptRegistered(cstype, csname1))
  {
       System.Text.StringBuilder cstext1 = new System.Text.StringBuilder();
       cstext1.Append("<script type='text/javascript'>");
       cstext1.Append("$('.datePicker').datetimepicker({ dateFormat: 'dd.mm.yy' });");
       cstext1.Append("</script>");

       cs.RegisterStartupScript(cstype, csname1, cstext1.ToString());
  }

最后我的“日期选择器”功能正在工作

cstext1.Append("$('.datePicker').datepicker({ dateFormat: 'dd.mm.yy' });");

但是“datetimepicker”说没有找到

cstext1.Append("$('.datePicker').datetimepicker({ dateFormat: 'dd.mm.yy' });");
4

2 回答 2

3

应用$(document).ready(function(){//Put your Script here});以告诉 jQuery 在页面中的所有 DOM 都准备好时加载此脚本。

于 2012-04-25T11:32:39.417 回答
0

之前有一个类似的问题......这些答案可能会帮助你......

检查这个这个...

于 2012-04-25T11:25:59.713 回答