1

我有一个安装了 glimpse 的 MVC 应用程序,我还使用 MVCControlToolkit 进行动态验证。

我遇到的问题是,当我有一个使用 DateTimeFor 显示日期时间日历并进行验证的视图时,但仅在非常有限的情况下(如果我只有 datetimefor 元素不会发生这种情况),主体会在页面两次。

看起来渲染正在被某些东西重新启动,但我无法解决它。

任何帮助,将不胜感激

我的查看代码是

    @using LeaveTracker.Models
@using LeaveTracker.Models.Leave
@using MVCControlsToolkit.Controls
@using MVCControlsToolkit.Controls.Validation
@model LeaveTracker.Models.Leave.LeaveAllocation

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutMaintenance.cshtml";
}

@Html.AntiForgeryToken()
<div class="page-header">
<h1>    
    Edit Leave Allocation 
    @if (Model.ID > 0) { <small> @Model.TypeOfLeave.Name till @Model.AppliesUntil.ToString("dd/MM/yyyy")</small> } 
</h1>
</div>

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")" type="text/javascript"></script>
@Html.JQueryDatePickerGlobalizationScript("en-GB")
<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 src="@Url.Content("~/Scripts/ValidationSetup.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MVCControlToolkit.Controls-1.5.0.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {

    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Leave Allocation Details</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="clearfix">
            @Html.LabelFor(model => model.TypeOfLeave)
            <div class="input">
                @Html.DropDownListFor(model => model.TypeOfLeave, 
                       LeaveFactory.GetAllLeaveTypes().Select(fl => new SelectListItem
                        {
                            Text = fl.Name,
                            Value = fl.ID.ToString()
                        }))
                <span class="help-inline">@Html.ValidationMessageFor(model => model.TypeOfLeave)</span>
            </div>  
        </div>

        <div class="clearfix">
            @Html.LabelFor(model => model.AppliesFrom)
            <div class="input">
                @Html.DateTimeFor(model => model.AppliesFrom, DateTime.Today, true).DateCalendar(
                    inLine: false,
                    calendarOptions: new CalendarOptions
                    {
                        ChangeYear = true,
                        ChangeMonth = true
                    })                  
                <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesFrom)</span>
            </div>  
        </div>

         <div class="clearfix">
            @Html.LabelFor(model => model.AppliesUntil)
            <div class="input">
                @Html.DateTimeFor(model => model.AppliesUntil, DateTime.Today, true).DateCalendar(
                    inLine: false,
                    calendarOptions: new CalendarOptions
                    {
                        ChangeYear = true,
                        ChangeMonth = true
                    })                
                <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesUntil)</span>
            </div>  
        </div>

        <div class="clearfix">
            @Html.LabelFor(model => model.DefaultAllocation)
            <div class="input">
                @Html.EditorFor(model => model.DefaultAllocation)
                <span class="help-inline">@Html.ValidationMessageFor(model => model.DefaultAllocation)</span>
            </div>  
        </div>

    </fieldset>

    <fieldset>

        <legend>Leave Carried Over</legend>

        <div class="clearfix">
            @Html.LabelFor(model => model.MaxCarriesOver)
            <div class="input">
                @Html.EditorFor(model => model.MaxCarriesOver)
                <span class="help-inline">@Html.ValidationMessageFor(model => model.MaxCarriesOver)</span>
            </div>  
        </div>

        <div class="clearfix">
            @Html.LabelFor(model => model.LeaveUseByDate)
            <div class="input">
                @Html.DateTimeFor(model => model.LeaveUseByDate, DateTime.Parse("01/01/1900"), true).DateCalendar(
                    inLine: false,
                    calendarOptions: new CalendarOptions
                    {
                        ChangeYear = true,
                        ChangeMonth = true
                    })               
                <span class="help-inline">@Html.ValidationMessageFor(model => model.LeaveUseByDate)</span>
                <span class="help-block">The year on this field doesn't matter, only the month and day will be taken into account</span>
            </div>  
        </div>

        <div class="actions">
            @Html.ActionLink("Cancel", "Index", null, new { @class = "btn" })            
            <input class="btn primary" type="submit" value='Save'>
        </div>

    </fieldset>
}
4

1 回答 1

3

李,

我们相信我们已经解决了这个问题。

您能否通过在http://www.myget.org/F/getglimpse/上从 MyGet 安装 Glimpse 0.87 的 alpha 版本进行测试和确认

如果我们确认这可以解决您的问题 - 并进行更多测试 - 我们将发布到主要的 NuGet.org 存储库。

EDIT Glimpse 0.87 版现在可从主要NuGet.org Glimpse 源获得

于 2011-11-17T14:35:50.803 回答