第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我對在控制器和視圖之間多次傳遞數(shù)據(jù)感到非常困惑

我對在控制器和視圖之間多次傳遞數(shù)據(jù)感到非常困惑

C#
哆啦的時光機 2023-06-25 13:38:19
當用戶單擊下拉列表的所選項目時,我需要獲取子 id,并且人們告訴我,我需要在控制器和視圖之間傳遞數(shù)據(jù)多次,我找到一個 ajax 代碼將該 id 發(fā)布到控制器,但它返回 null。這是執(zhí)行此操作的正確方法嗎?我的看法 :@using (Html.BeginForm()){<table class="table table-hover">    <tr>        <td>            @Html.Label("PersonalAd?")        </td>        <td>@Html.EditorFor(model => model.PersonalName)</td>    </tr>    <tr>        <td> @Html.Label("Departman")</td>        <td> @Html.EditorFor(model => model.PersonalDepartment)</td>    </tr>    <tr>        <td>@Html.Label("IseGirisTarihi")</td>        <td>@Html.EditorFor(model => model.IseGirisTarihi)</td>    </tr>    <tr>        <td>            @Html.DisplayNameFor(model => model.FormDetail.Form)        </td>        <td>            @Html.DropDownListFor(model => model.FormDetail.FormId,           Model.FormViewList)        </td>    </tr>    <tr>        <td>            @Html.DisplayNameFor(model => model.FormDetail.CheckListType)        </td>        <td>            @Html.DropDownListFor(model =>   model.FormDetail.CheckListTypeId, Model.checkLists, new  {@id="Selection",  @class = "drop-open" })        <td><button onclick="">Bolum Ekle</button></td>    </tr>    <tr>        <td colspan="2" style="padding-top:40px;">            <input type="submit" value="Save" class="btn btn-info" />        </td>    </tr></table><script src="~/Scripts/jquery-3.1.1.min.js"></script><script src="~/Content/js/open.js"></script>}我的控制器:[HttpGet]public ActionResult Add(){        FormDetailViewModel model = new FormDetailViewModel();        foreach(Form item in formRep.List().ProcessResult)        {            FormList.Add(new SelectListItem { Value = item.FormId.ToString(), Text = item.TeslimEden });        }        foreach(Item item in itemRep.List().ProcessResult)        {            ?temList.Add(new SelectListItem { Value = item.ItemId.ToString(), Text = item.ItemDesc });        }
查看完整描述

1 回答

?
呼啦一陣風

TA貢獻1802條經(jīng)驗 獲得超6個贊

控制器 :


[HttpPost]

public JsonResult GetDataById(int id) {

    //your logic

    ....

    //response - return data which is required in your ajax success.

    return Json(response, JsonRequestBehavior.AllowGet); 

}

杰斯:


$('#Selection').on('change', function () {

var id = $('#Selection option:selected').text();


$.ajax({

    url: '@Url.Action("GetDataById", "FormDetail")',

    type: "POST",

    data: { 'id': id }, 

    success: function (result) {

        $('#ajaxDisplay').html(result);

    }

  });

});


查看完整回答
反對 回復(fù) 2023-06-25
  • 1 回答
  • 0 關(guān)注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號