Shu*_*Shu 4 javascript vb.net jquery razor asp.net-mvc-4
在我的MVC4剃须刀引擎中,我需要从文本框中选择日期作为我的视图
<tr>
<td>Start Date</td>
<td>@Html.TextBox("RateListStartDate")</td>
</tr>
<tr>
<td>End Date</td>
<td>@Html.TextBox("RateListEndDate")</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
当我点击开始日期或结束日期的文本框时,它应该显示日历,任何链接/代码/建议?
由于您使用MVC,jQuery"应该"已在您的布局页面中引用.您还需要jqueryUI.
如果datepicker代码向您投掷错误,请将以下两行添加到您的视图或布局页面:
<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>
Run Code Online (Sandbox Code Playgroud)
然后你需要声明元素,这应该是获得datepicker功能.
$(document).ready(function(){
$(".getdate").each(function() {
$(this).datepicker();
});
});
Run Code Online (Sandbox Code Playgroud)
并相应地编辑你的Html.TextBoxFor():
@Html.TextBox("RateListStartDate", new {@class="getdate"})
Run Code Online (Sandbox Code Playgroud)
这应该可以解决问题.亲切的问候
归档时间: |
|
查看次数: |
50921 次 |
最近记录: |