0

送信ボタンが FORM ページで機能しません。同じ質問に対して多くの解決策を読みましたが、問題を修正できませんでした。誰かがエラーを指摘したり、変更を提案したりできますか...??

abc.cshtml

     @using (Ajax.BeginForm("ABC", "Queries", null, new AjaxOptions { HttpMethod = "Post",  UpdateTargetId = "content", LoadingElementId = "mask" }, new { enctype = "multipart/form- data", id = "intake_form", **@class** = "inline-form clear_both" }))
    {


     <div class="form_row">
        <div class="form_col1">
            <label class="QueryPageHeadings">
                Title*</label>
        </div>
        <div class="form_col2" style="z-index: 24; position: relative;" id="queryTitle_div">
    @Html.TextBoxFor(m => m.ABC.QueryTitle, new { @class = "text QueryFormTextBox" })
            <br />
            <div style="float: left">
                @Html.ValidationMessageFor(m => m.ABC.QueryTitle)
            </div>
        </div>

    </div>
   <div class="form_row">
        <div class="form_col1">
            <label class="QueryPageHeadings">
                Specific Notes</label>
        </div>
        <div class="form_col2" style="z-index: 21; position: relative;" id="specific_note_div">
            @Html.TextAreaFor(m => m.ABC.SpecificNotes, new { @class = "text QueryFormTextBox", style = "resize:none;height:160px;" })
            <br />
            <div style="float: left">@Html.ValidationMessageFor(m => m.ABC.SpecificNotes)</div>

        </div>
    </div>
    <div class="form_row">
        <div class="form_col1">
            <label class="QueryPageHeadings">
                Supporting Document
            </label>
        </div>
        <div class="form_col2">
            <div style="width:100%;float:left;">
            @Html.TextBoxFor(m => m.ABC.SupportDocument, new { @Id = "lblFileName", @readonly = "readonly" })
            </div>
            <div style="width:100%;float:left;">
            <button id='btnUploadPopup' type="button" style="float:left;" onclick="javascript:OpenFileUpload();">
                Upload Files</button>
                </div>

        </div>

    </div>
    <div class="form_row form_footer">                          
        <p class="indent">
                <input class="secondary button float_right" value="Submit" type="submit" name="button" />                                 
        </p>
    </div>
     }

Controller.cs

    [HttpPost]
    public ActionResult ABC(ABCViewModel model, string button)
    {

            String errorMessage = "";
            if (String.IsNullOrEmpty(errorMessage))
            {
                errorMessage = errorMessage + " Fields can not be empty.";
            }
            if (!String.IsNullOrEmpty(errorMessage))
            {
                Session["errorMessage"] = errorMessage;
                IABC data = new ABCViewModel();

                data.ABC.QueryTitle = model.ABC.QueryTitle;
                data.ABC.SpecificNotes = model.ABC.SpecificNotes;
                data.ABC.SupportDocument = model.ABC.SupportDocument;

                TempData["isEdit"] = false;
                return View("ABC", data);
            }
            else
            {
                Session["errorMessage"] = "";
                Session.Remove("errorMessage");
            }


            Session["fileName"] = null;
            return View();

    }  
4

3 に答える 3

0

あなたのコードを「そのまま」コピーして貼り付けましたが、うまくいきました。ほぼ :) (コンパイラ エラーのため、**@class**' ' を ' ' に変更しました)。@class

空のプロジェクトでそれを繰り返してみてください。もしかして何か変わった?

于 2013-11-12T11:26:19.667 に答える
0

AJAX 投稿を行っているため、必要な Java スクリプトが不足している可能性があります。ファイルに次を追加し_Layout.chtmlます。

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>

[HttpPost]また、コントローラーメソッドを属性で装飾する必要があります。

PS: 非同期ポージングが必要ない場合は、Html.BeginForm代わりに を使用してAjax.BeginFormください。

于 2013-11-12T10:47:45.000 に答える