Вставить изображение в папку Показать нулевое значение в контроллере - PullRequest
0 голосов
/ 11 октября 2018

Я хочу вставить изображение на стороне клиента.URL-адрес изображения вставлен в сетку, но когда я нажимаю кнопку «Сохранить», URL-адрес изображения не передается в контроллер и показывает нулевое значение результата.Но URL-адрес изображения отображается в столбце изображения сетки, но не передается контроллеру.

И второй вопрос: когда я загружаю изображение, тогда отображается только URL-адрес изображения, которое я хочу отображать, вид изображения. Можете ли вы дать мне представление о том, какЯ отображаю изображение в этом коде.

c #

 [HttpPost]
        public ActionResult mQuotationInsert(int Qt_ID, string EnteryDate, string Purpose, Quotation[] Quot, string AddNew)
        {
            string result = "Error! Order Is Not Complete!";
            try
            {
                objQuotation.QuotationInsert(Qt_ID, EnteryDate, Purpose, Quot, AddNew);
                ModelState.Clear();
                result = "Quotation Inserted Successfully!";
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                throw;
            }

        }

Javascript

// Add Multiple Record
    $("#addToList").click(function (e) {
            e.preventDefault();

            if ($.trim($("#PartyName").val()) == "" || $.trim($("#txtfile").val()) == "") return;

        var Srno = document.getElementById("detailsTable").rows.length,
            PartyName = $("#PartyName").val(),
            image = $("#txtfile").val(),
            IsMature = $("#chkNIsMature").is(":checked"),
            detailsTableBody = $("#detailsTable tbody");
            var Qt = '<tr><td>' + Srno + '</td><td>' + PartyName + '</td><td>' + image + '</td><td>' + IsMature+ '</td><td> <a data-itemId="0" href="#" class="deleteItem">Remove</a></td></tr>';
            detailsTableBody.append(Qt);
            clearItem();
    });



  $("#saveQuotation").click(function (e) {
            e.preventDefault();
            var QuotationArr = [];
            QuotationArr.length = 0;

            $.each($("#detailsTable tbody tr"), function () {

                QuotationArr.push({
                    Srno: $(this).find('td:eq(0)').html(),
                    PartyName: $(this).find('td:eq(1)').html(),
                    image: $(this).find('td:eq(2)').html(),
                    IsMature: $(this).find('td:eq(3)').html()
                });
            });

            var data = JSON.stringify({
                Qt_ID: parseInt($("#txtQtID").val()),
                EnteryDate: $("#txtNEnteryDate").val(),
                Purpose: $("#txtNPurpose").val(),
                Quot: QuotationArr,
                AddNew: $("#AddNew").val()
            });

            $.when(saveQuotation(data)).then(function (response) {
                console.log(response);
            }).fail(function (err) {
                console.log(err);
            });
        });

HTML

 <!--Detail-->
                            <h5 style="margin-top:10px;color:#ff6347">Quotation Details</h5>
                            <hr />
                            <div>
                                <div class="form-row">
                                    <div class="col">

                                        <div class="md-form">
                                            <label for="lblPartyName">Party Name</label>
                                            <input type="text" id="PartyName" name="PartyName" placeholder="Party Name" class="form-control" ,Required=true />


                                        </div>
                                    </div>
                                    <div class="col">

                                        <form class="md-form">
                                            <label for="lblPartyName">Image File</label>
                                            <div class="file-field">
                                                <div class="btn btn-outline-success  btn-sm float-left">

                                                    <input type="file" id="txtfile" name="file">
                                                </div>
                                                <div class="file-path-wrapper" hidden>
                                                    <input class="file-path validate" type="text" placeholder="Upload your file">
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="col">
                                        <!-- IsMature-->
                                        <div class="custom-control custom-checkbox custom-control-inline">
                                            @Html.CheckBoxFor(m => m.IsMature, new { @class = "custom-control-input", @id = "chkNIsMature" })

                                            <label class="custom-control-label" for="chkNIsMature">Mature</label>
                                        </div>
                                    </div>


                                    <div class="col-md-2 col-lg-offset-4">
                                        <a id="addToList" class="btn btn-primary">Add To List</a>
                                    </div>
                                </div>
                                <table id="detailsTable" class="table">
                                    <thead style="background-color:#007bff; color:white">
                                        <tr>
                                            <th style="width:2%">SrNo.</th>
                                            <th style="width:40%">Party Name</th>
                                            <th style="width:30%">Image</th>
                                            <th style="width:30%">Mature</th>
                                            <th style="width:10%"></th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...