1

垣間見ることができるMVCアプリケーションがインストールされています。また、動的検証にMVCControlToolkitを使用しています。

私が抱えている問題は、DateTimeForを使用して検証付きの日時カレンダーを表示するビューがある場合ですが、非常に限られた状況でのみ(datetimefor要素しかない場合はこれは発生しません)、本文がレンダリングされますページを2回。

レンダリングが何かによって再開されているように見えますが、私はそれを解決することができませんでした。

どんな助けでもいただければ幸いです

私のビューコードは

    @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

リー、

この問題は修正されたと考えています。

MyGet ( http://www.myget.org/F/getglimpse/ ) から Glimpse 0.87 のアルファ ビルドをインストールして、テストおよび確認していただけますか。

これにより問題が修正されたことが確認された場合 (そしてもう少しテストを行った後)、メインの NuGet.org リポジトリにリリースされます。

EDIT Glimpse バージョン 0.87 がメインのNuGet.org Glimpse フィードから入手できるようになりました

于 2011-11-17T14:35:50.803 に答える