1

我的代码:

@using Telerik.Web.Mvc.UI;
@using Telerik.Web.UI;

@{
    ViewBag.Title = "Home Page";
}
<script type="text/javascript" src="~/Scripts/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.8.11.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.8.20.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.9.0.custom.min.css"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.9.0.custom.css"></script>

<script type="text/javascript">
    console.log($)
</script>
@(Html.Telerik().DatePicker()
    .Name("DatePickerDOB")
    .HtmlAttributes(new { style = "width: 140px; " })
)

@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
                <h2>@ViewBag.Message</h2>
            </hgroup>
            <p>
                To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
                    http://asp.net/mvc</a>. The page features <mark>videos, tutorials,
                        and samples</mark> to help you get the most from ASP.NET MVC. If you have
                any questions about ASP.NET MVC visit <a href="http://forums.asp.net/1146.aspx/1?MVC"
                    title="ASP.NET MVC Forum">our forums</a>.
            </p>
        </div>
    </section>
}
<h3>We suggest the following:</h3>
<ol class="round">
    <li class="one">
        <h5>Getting Started</h5>
        ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
        enables a clean separation of concerns and that gives you full control over markup
        for enjoyable, agile development. ASP.NET MVC includes many features that enable
        fast, TDD-friendly development for creating sophisticated applications that use
        the latest web standards. <a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn
            more</a></li>
    <li class="two">
        <h5>Add NuGet packages and jump start your coding</h5>
        NuGet makes it easy to install and update free libraries and tools. <a href="http://go.microsoft.com/fwlink/?LinkId=245153">
            Learn more</a></li>
    <li class="three">
        <h5>Find Web Hosting</h5>
        You can easily find a web hosting company that offers the right mix of features
        and price for your applications. <a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn
            more</a></li>
</ol>

当我单击 datepicker 文本字段时,我不知道我需要做些什么来显示 DatePicker。请帮忙。谢谢。

4

1 回答 1

1

没什么不好的

@(Html.Telerik().DatePicker()
    .Name("DatePickerDOB")
    .HtmlAttributes(new { style = "width: 140px; " })
)

它在我的项目中运行良好(尽管单击图标时会打开日历,而不是文本框,但我认为此时这实际上不是您的问题)。

检查以确保

@(Html.Telerik().ScriptRegistrar()

正在被调用。通常这是在 _Layout 中,但可以使用 Telerik 控件直接放入文件中。

附带说明(我认为这不会导致您的问题,但肯定没有任何帮助),这些行是错误的:

<script type="text/javascript" src="~/Scripts/jquery-ui-1.9.0.custom.min.css"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.9.0.custom.css"></script>

.css 文件不是脚本。应该像这样引用它们:

<link href="~/Scripts/jquery-ui-1.9.0.custom.min.css" rel="stylesheet" type="text/css"/>

而且您似乎实际上并没有在此页面上使用任何 jQuery,因此您可能不需要导入所有这些脚本和 css 文件。Telerik 使用自己的 jQuery 脚本,这就是脚本 Registrar 的用途。

于 2012-10-23T15:57:16.773 回答