2013-10-09 70 views
0

好吧我已经成功地在我的其他项目上做到这一点。
不幸的是,它不适用于目前正在进行的项目,有人可以提供关于我的代码tnx有什么错误的见解!jquery datepicker不弹出

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="NonOperatingDays.WebForm1" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <style type="text/css"> 
    .ui-datepicker 
      { 
      background: #FFFFFF; 
      border: 1px solid #888888; 
      color: #888888; 
      } 
      </style> 
     <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script> 
    <script src="Scripts/jquery.ui.datepicker.js" type="text/javascript"></script> 
</head> 
<body> 
    <script type="text/javascript" language ="javascript"> 
     function pageLoad() { 
      $(function() { 
       $(".datepicker").datepicker({ dateformat: "YYYY-MM-DD" }); 
      }); 
     } </script> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:TextBox ID="TextBox1" runat="server" CssClass="datepicker"></asp:TextBox> 
    </div> 
    </form> 
</body> 
</html> 
+0

检查您的控制台,你得到任何错误? –

回答

3

实际上完成@Wilson黄答案,而不是使用页面加载,你必须使用jQuery的准备,否则jQuery的小部件不会工作

$(document).ready(function() { 
    $(".datepicker").datepicker({ dateFormat: "yy-mm-dd" }); 
    }); 

还要确保DATEFORMAT是骆驼套管,不要忘记添加CSS和JavaScript链接

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
+0

:(我试图用您的代码替换我的代码。并将您的脚本放在头标签仍然不工作:(我不知道这是什么原因背后 – zxc

+0

看到这是jsfiddle.net/kia3d/NpU34/的jsfiddle.net和它完美的工作 – Kiarash

+0

它已经修复? – Kiarash

0

看看:http://api.jquery.com/ready/

你并不需要 “功能页面加载()”。

<script type="text/javascript"> 
    $(function() { 
    $(".datepicker").datepicker({ dateformat: "yy-mm-dd" }); 
    }); 
    </script> 
+0

tnx回答!我试过这一个仍然不工作:( – zxc

0

这里是工作代码:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="Head1" runat="server"> 
    <title></title> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
<script type="text/javascript"> 
    $(function() { 
     $(".datepicker").datepicker({ dateFormat: 'yy-MM-dd' }); 
    }); 
</script> 

<form id="form1" runat="server"> 
    <div> 
     <asp:TextBox ID="TextBox1" runat="server" CssClass="datepicker"></asp:TextBox> 
    </div> 
</form>