在 ASP.NET MVC3 中使用 jQuery 的具有可点击日期的事件日历
我即将创建一个解决方案,该解决方案将列出将在特定日期发生的事件,并且正在寻找一个日历控件,我可以处理该控件以仅使有事件的日期可单击,当然还可以接收此单击事件并处理在我的控制器中休息。 (类似于 Webforms 中旧的 asp:Calendar 服务器端控件)。
有符合这个场景的吗?
更新:我正在寻找的是一个迷你日历,而不是像 Outlook 中的完整日历。
这就是我正在寻找的:
I'm about to create a solution that will list events that will occur in specific days, and was looking for a Calendar control that I can deal with to make only the days with events clickable, and of course receive this click event and handle the rest myself in my Controller.
(something like the old asp:Calendar server-side control in Webforms).
is there any that match this scenario?
Update: What I'm exactly looking for is a Mini Calendar, not a full Calendar like the one in Outlook.
this is what I'm exactly looking for:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
jQuery UI 可以实现您想要的确切样式。(和功能)
您将需要下载 jQuery UI 脚本和 平滑度主题(访问http://jqueryui.com /download/ 并从单选按钮中选择核心和日期选择器,并从右侧的下拉列表中选择平滑度)
html
javascript
activeDays
变量可以直接保存日期(而不仅仅是日期数字),您需要更改函数内的条件以检查匹配。isActive
是一个用于控制活动日期样式的类。实时示例位于 http://jsfiddle.net/gaby/C95nx/2/
上面的代码和示例呈现为
jQuery UI can do the exact styling you want.. (and functionality)
You will need to download the jQuery UI script and the Smoothness theme (visit http://jqueryui.com/download/ and select core and datepicker from the radio buttons, and smoothness from the drop-down to the right)
html
javascript
The
activeDays
variable could hold dates directly (instead of just the day number) and you would need to alter the conditional inside the function to check for a match.The
isActive
is a class used to control the styling of the active dates..Live example at http://jsfiddle.net/gaby/C95nx/2/
the above code and example renders as
几年前,我通过大量修改名为 的 javascript 日历,做了类似的事情MooTools 事件日历
还有其他几个看起来也不错的 JavaScript 日历。
这两个使用 JQuery:
I made something like this a couple of years ago by heavily modifying a javascript calendar called MooTools Event Calendar
There are several other javascript calendars that look pretty good as well.
These 2 use JQuery:
您可以将 jquery UI datepicker 与
beforeShowDay
事件一起使用来自定义哪些日期可以选择,哪些日期不可以。这是禁止选择日期 5 的最小代码,您可以扩展逻辑。这是一个快速演示
You can use jquery UI datepicker along with the
beforeShowDay
event to customize which days are selectable and which days are not. Here is the minimal code which disables selecting the date 5 and you can extend the logic.Here's a quick demo
许多人使用 jQuery UI 日期选择器。我不确定日历的内置 asp.net mvc 控件。
Many people use the jQuery UI datepicker. I'm not sure of a built in asp.net mvc control for the calendar.
如果您仍然可以在代码中使用 Javascript,请使用此控件并自定义其 UI。它具有可满足您自己的定制要求的源代码。
http://www.javascriptkit.com/script/script2/eventscalendar.shtml#< /a>
If you can still use Javascript in your code, take this control and customize its UI. It has source code available for your own customization requirements.
http://www.javascriptkit.com/script/script2/eventscalendar.shtml#
我意识到这个答案已经太晚了,但你的问题在谷歌结果中排名很高,所以希望它能帮助其他人。我在这里写了一篇关于这个主题的文章:
基于日期选择器的 MVC3 事件日历
I realise this is beyond late as an answer, but your question is quite high up in Google results, so hopefully it will help other people. I wrote an article on this very topic here:
Datepicker based MVC3 Events Calendar
如何限制 jquery ui 日期选择器中的可用天数< /a>
或
http://test.thecodecentral.com/cms/jqueryui/datepicker/< /a>
How to limit days available in jquery ui date-picker
or
http://test.thecodecentral.com/cms/jqueryui/datepicker/
您可以将 MVC 与 silverlight 集成并使用 silverlight 日历
http://developerstyle.posterous.com/silverlight-calendar-with-mvc-3
You can integrate MVC with silverlight and use silverlight calendar
http://developerstyle.posterous.com/silverlight-calendar-with-mvc-3
为了补充 @gaby-aka-g-petrioli 的答案,我添加了允许获取点击操作的
onChangeMonthYear
和onSelect
方法。In order to complement @gaby-aka-g-petrioli's answer I included
onChangeMonthYear
andonSelect
methods that allows get click actions.