0

部分的なビューをレンダリングするビューがあり、このビューにはチェックボックスのリストを含むダイアログボックスがあります。このビューは作成と呼ばれます。

このページのプロセスフローは次のとおりです。

1)ユーザーがこのページを初めて開くときは、ファイルを選択してアップロードボタンを押すことでファイルをアップロードします。actionメソッドはファイルを解析してモデルを返し、一連の日付をチェックボックスリストの形式でダイアログボックスに表示します。

2)このダイアログボックスから日付を選択/チェックし、ダイアログボックスの選択ボタンを使用して、選択したチェックボックスに基づいていくつかのフォームフィールドを計算し、部分ビューを返すコントローラーアクションにPOSTリクエストが行われます。

3)ユーザーが事前に入力されたフィールドが返されても問題がない場合は、[保存]をクリックして記録を保存します。

[作成]ページではすべて正常に機能します。編集ページでは別の話のようです。ページが最初にロードされると、作成時に保存されたリストがダイアログボックスに表示されます。ただし、ダイアログボックス内で[選択]をクリックすると、アクションメソッドへの投稿はこのリストを空として受け取ります。なぜnullなのかわかりません。正確に何が間違っているのかわかりませんが、編集用のコードは次のとおりです。

ありがとう!!

JSファイル:

var RunDialog;

$(document).ready(function () {

    $(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

    RunDialog = $("#runDatestreeview").dialog({ closeOnEscape: true, stack: false, autoOpen: false,
        modal: false, resizable: true, draggable: true, title: 'Select Run Dates to Auto-Populate Form Fields:',
        width: 600, height: 500, position: 'center',
        buttons: { Select: function () {
            $.post("/RunLogEntry/LogFileConfirmation",
              $("#form").serialize(),
               function (data) {
                   $("#runDatestreeview").remove();
                   $("#testExceptiontreeview").remove();
                   $("#main").html(data);
                   $(RunDialog).dialog("close");
               }, "html");
        },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    RunDialog.closest("div.ui-dialog").appendTo("#form");


    $('#RunDatesChildDialogLink').click(function () {
        $(RunDialog).dialog("open");
    });


    //Region Auto-Open Modal Box
    var modalOpen = $("#LogModals").val();

    if (modalOpen == "0") {
        $("#runDatestreeview").dialog({ autoOpen: true });
    }
    //End Auto Open Modab Box Regiom


});

ビューを編集

@model RunLog.Domain.Entities.RunLogEntry
@{
    ViewBag.Title = "Update";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<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/runLogEntry.js")" type="text/javascript"></script>
<script type="text/javascript">
    var runlogListErrorsUrl = '@Url.Action("ListErrorCodes", "RunLogEntry")';
</script>
@using (Html.BeginForm("Edit", "RunLogEntry", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 
    <div id="main">
        @Html.Partial("_RunLogEntryPartialViewEdit", Model)
    </div>

}
<script src="@Url.Content("~/Scripts/exitCode.js")" type="text/javascript"></script>

編集用の部分表示読みやすくするために、モデル全体を投稿しているわけではありません。Dialogdivはと呼ばれrunDAtestreeviewます。

@model RunLog.Domain.Entities.RunLogEntry
<script src="@Url.Content("~/Scripts/runDates.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/testexception.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.blockUI.js")" type="text/javascript"></script>
@Html.ValidationSummary(true)

<div class="bodyContent">
    @if (Model.RunDatesDisplay != null && Model.RunDatesDisplay.Count() > 0)
    {
        <span class="leftContent">
            @Html.Label("Run Dates")
        </span><span class="rightContent"><span id="RunDatesChildDialogLink" class="treeViewLink">
            Click here to Select/View Run Dates</span>
            <br />
            <span id="RunDatesDisplayy" style="cursor: pointer; text-decoration: underline;">
            </span></span>
    }
</div>

<div id="runDatestreeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
    overflow: scroll; width: 400px; height: 450px; display: none;">
    <table class="grid" style="width: 600px; margin: 3px 3px 3px 3px;">
        <thead>
            <tr>
                <th>
                    Run Dates:
                </th>
                <th>
                    Minimum Replicate:
                </th>
            </tr>
        </thead>
        <tbody>
            @Html.EditorFor(x => x.RunDatesDisplay)
        </tbody>
    </table>
</div>
4

1 に答える 1

0

これは些細なことのようですが、「id = form」を含めることでフォームを次のように変更すると、機能しました。以前、選択ボタンをクリックしていたとき、フォームはnullでした。

@using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { id = "form", enctype = "multipart/form-data" }))
{
于 2013-01-10T05:55:53.220 に答える