textfield不显示从mvc3中的jquery datepicker中选取的日期?

时间:2011-03-27 17:07:41

标签: asp.net-mvc-3 jquery-ui-datepicker

<script type="text/javascript">  
    $(document).ready(function () 
    {  
        $('.date').datepicker  
            ({  
                dateFormat: 'mm/dd/yyyy',  
                 showStatus: true                
                }  
            });  
        });  

</script>  
<div>  
    Date: <input type="text" id="datepicker"/>  
</div>  
<div>  
     @Html.TextBox("toDate", Model.toDate.ToString("dd/MM/yyyy"), new { @class = "date" })  
</div>     

以上是cshtml页面..我很无能为什么我点击日期选择器的日期不会出现在texbox /输入上..你能帮忙吗?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>WeeklyReport</title>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <link href="//Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="//Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="//Scripts/jquery-ui.min.js" type="text/javascript"></script>
    <script src="//Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="//Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
    <script src="//Scripts/jquery.infieldlabel.min.js" type="text/javascript"></script>
</head>
<body>
</div>
    <div class="content">
         <div class="topSpacer">
        </div>
        <div class="maincontent">
            <script type="text/javascript"> 
    $(document).ready(function () {
        $('.date').datepicker
            ({
                dateFormat: 'mm/dd/yyyy',
                 showStatus: true,
                highlightWeek: true,
                showAnim: "scale",
                firstDay: 6,
                showOptions: {
                    origin: ["top", "left"]},
                 onSelect:    function() {         
                }
            });


        });

    $(function() {
        $("#datepicker").datepicker();
    });

</script>
<div>
    Enter search criteria
</div>
<div style="float: left">
<p>Date: <input type="text" id="datepicker"/></p>

</div>
<div style="float: left; padding-left: 30px">
    <input class="date" id="toDate" name="toDate" type="text" value="15/12/2011" />&nbsp
    EndDate
</div>


        </div>
    </div>
</body>
</html>
   `

1 个答案:

答案 0 :(得分:1)

这是什么乱七八糟的?你在问什么?在你的问题中,你没有显示代码的样子,所以我们只能在这里猜测。通常,当您提出问题时,您应该准确地显示代码的外观。

所以我想通过一个有效的例子来改进你的代码:

查看:

@model AppName.Models.SomeViewModel
<script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('.date').datepicker({
            showStatus: true,
            highlightWeek: true,
            showAnim: 'scale',
            firstDay: 6,
            showOptions: {
                origin: [ 'top', 'left' ]
            },
            onSelect: function () {

            }
        });
        $('#datepicker').datepicker();
    });
</script>

<div>  
    Date: <input type="text" id="datepicker"/>  
</div>  
<div>  
    @Html.TextBox(
        "toDate", 
        Model.toDate.ToString("dd/MM/yyyy"), 
        new { @class = "date" }
    )
</div>