Telerik MVC 扩展日期选择器未将日期放入文本框中

发布于 2024-12-28 02:54:58 字数 1517 浏览 3 评论 0原文

我正在使用 ASP.NET MVC 3razor 以及最新版本的 Telerik MVC 扩展 控件。

我的视图上有一个日期选择器:

<td><label>From:</label></td>
<td>
     @(Html.Telerik()
          .DatePickerFor(x => x.HospitalisedStartDate)
          .Name("HospitalisedStartDate")
     )
</td>

我的视图模型中的此属性:

public DateTime? HospitalisedStartDate { get; set; }

加载视图时,我将单击日历图标。日历弹出,我选择一个日期,然后什么也没有发生。日历消失,但文本框中未设置日期。为什么会这样呢?如果我在文本框中输入“今天”一词,那么它会输入今天的日期,例如“2012/01/21”。我在这里缺少什么阻止它工作?

样式表和 JavaScript 的标记如下所示:

<link type="text/css" href="/Content/2011.3.1115/telerik.common.min.css" rel="stylesheet"/>
<link type="text/css" href="/Content/2011.3.1115/telerik.webblue.min.css" rel="stylesheet"/>
<link type="text/css" href="/Content/Stylesheets/mystylesheet.css" rel="stylesheet"/>

<script src="/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.common.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.tabstrip.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.calendar.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.datepicker.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.treeview.min.js"></script>

I am using ASP.NET MVC 3 with razor and the latest version of the Telerik MVC extensions controls.

I have a date picker on my view:

<td><label>From:</label></td>
<td>
     @(Html.Telerik()
          .DatePickerFor(x => x.HospitalisedStartDate)
          .Name("HospitalisedStartDate")
     )
</td>

This property in my view model:

public DateTime? HospitalisedStartDate { get; set; }

When the view loads, I would click on the calendar icon. The calendar pops up, I would select a date and then nothing happens. The calendar disappears but the date is not set the textbox. Why would this be? If I were to type in the word "today" in the textbox then it will put in todays date like "2012/01/21". What am I missing here that is preventing it from working?

The markup looks like this for the style sheets and JavaScript:

<link type="text/css" href="/Content/2011.3.1115/telerik.common.min.css" rel="stylesheet"/>
<link type="text/css" href="/Content/2011.3.1115/telerik.webblue.min.css" rel="stylesheet"/>
<link type="text/css" href="/Content/Stylesheets/mystylesheet.css" rel="stylesheet"/>

<script src="/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.common.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.tabstrip.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.calendar.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.datepicker.min.js"></script>
<script type="text/javascript" src="/Scripts/2011.3.1115/telerik.treeview.min.js"></script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

少跟Wǒ拽 2025-01-04 02:54:58

使用 jQuery 1.7 及更高版本时,日期选择器似乎存在问题。我将其更改为 jQuery 1.6.4,现在可以使用了。有谁知道为什么会出现这种情况?

现在我的看法是:

<script src="/Scripts/jquery-1.6.4.min.js"></script>

There seems to be an issue with the date picker when using jQuery 1.7 and higher. I changed it to jQuery 1.6.4 and it works now. Does any body know why this is the case?

This is now in my view:

<script src="/Scripts/jquery-1.6.4.min.js"></script>
冷月断魂刀 2025-01-04 02:54:58

你更新了 jQuery 吗?

在仔细考虑了我可能要更改的内容之后,我记得我需要测试更新版本的 jQuery。大约一周前,我用 jquery-1.7.1.js 替换了文件 jquery-1.6.4.min.js 。恢复 1.6.4 版本解决了我的问题。我的页面完全按照设计的方式工作。

Have you updated jQuery?

After thinking carefully about what I might have changed, I remembered that I needed to test a newer version of jQuery. I had replaced the file jquery-1.6.4.min.js with jquery-1.7.1.js about a week ago. Restoring the 1.6.4 version has fixed my problem. My page worked exactly the way it was designed to work.

月下客 2025-01-04 02:54:58

jQuery 1.6.4 对我来说工作得很好。但是,我尝试了jquery-1.5.1.min.js,也尝试了1.7.1。但它不起作用。图标没有显示。

jQuery 1.6.4 works just fine for me. However, I tried jquery-1.5.1.min.js and also tried 1.7.1. and it did not work. The icon was not showing up.

羞稚 2025-01-04 02:54:58

我也有同样的问题。我正在使用 MVC3(非 Razor)、Telerik MVC Controls 和 jQuery。我最近才开始看到这个问题。不幸的是,我似乎无法隔离我可能改变了什么来引发这种行为。我最近不得不添加 ASP.NET 脚本管理器来从第 3 方程序集导入脚本资源,以及一些自定义代码来帮助生成冗余标记。

为了回答 Nick 的问题,Telerik 控件会自动

<%: Html.Telerik().ScriptRegistrar() ... %>

在标记中插入一行,但从我的项目开始时就一直存在 - 当 DatePicker 按预期工作时。

我在 Firefox 和 IE 中都看到了这种行为。在纯粹的绝望中,我将我的文件精简为以下内容:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html>
  <head runat="server">
    <title>Test</title>
    <%: Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.webblue.css").Combined(true).Compress(true)) %>
  </head>
  <body>
    <form id="frmMain" method="post" runat="server">
      <% Html.Telerik( ).DatePicker( )
            .Name( "dtTest" )
            .HtmlAttributes( new { id = "dtTest_wrapper" } )
            .Min( DateTime.Today.Subtract( new TimeSpan( 3835, 0, 0, 0, 0 ) ) )
            .Max( DateTime.Today.Add( new TimeSpan( 24, 0, 0 ) ) )
            .ShowButton( true )
            .OpenOnFocus( true )
            .Render( ); %>
    </form>
    <%: Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(false).Compress(false)) %>
  </body>
</html>

这仍然没有按应有的方式工作。这是一个母版页(一直都是),但在任何子页面中都没有定义任何内容(从来没有)。

I'm having this same problem. I'm using MVC3 (non-Razor), Telerik MVC Controls, and jQuery. I've only recently started seeing this problem. Unfortunately, I can't seem to isolate what I might have changed to spark this behavior. I've recently had to add an ASP.NET Script Manager to import script resources from a 3rd party assembly, as well as some custom code to assist with generating redundant markup.

In response to Nick's question, the Telerik controls automagically insert a

<%: Html.Telerik().ScriptRegistrar() ... %>

line into the markup, but that's been there since the beginning of my project - when the DatePicker worked as expected.

I am seeing this behavior in both Firefox and IE. In sheer desperation, I stripped my file down to exactly this:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html>
  <head runat="server">
    <title>Test</title>
    <%: Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.webblue.css").Combined(true).Compress(true)) %>
  </head>
  <body>
    <form id="frmMain" method="post" runat="server">
      <% Html.Telerik( ).DatePicker( )
            .Name( "dtTest" )
            .HtmlAttributes( new { id = "dtTest_wrapper" } )
            .Min( DateTime.Today.Subtract( new TimeSpan( 3835, 0, 0, 0, 0 ) ) )
            .Max( DateTime.Today.Add( new TimeSpan( 24, 0, 0 ) ) )
            .ShowButton( true )
            .OpenOnFocus( true )
            .Render( ); %>
    </form>
    <%: Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(false).Compress(false)) %>
  </body>
</html>

This still isn't working the way it should. This is a master page (always has been), but there's nothing defined in any of the child pages, yet (never has been).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文