How to obtain data from a form using method=“post”? How to request it data in my controller?

后端 未结 4 1087
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 05:19

I am trying to obtain data from my html code like the \"acquringCode\", \"cardAcceptor\", and \"merchantId\". I can\'t figure how how to obtain that data in my controller.

4条回答
  •  生来不讨喜
    2020-12-22 06:06

    //Also note since i have the razor engine you will notice my views are using // @html.TextBoxFor...However if you dont have razor engine... then you would be using // Something like <%Html.TextBoxFor. //

    //Controller logic

        [HttpPost]
        public ActionResult AddSaveTreventLocationLookup(TreventModel model)
        {
    
                string acquiringInstitutionIdentificationCode;  
                string cardAcceptorIdentificationCode;
                string merchantId;
    
                acquiringInstitutionIdentificationCode =   model.AcquiringInstitutionIdentificationCode;
                cardAcceptorIdentificationCode = model.CardAcceptorIdentificationCode;
                merchantId = model.MerchantId;
    
                //
    
            return RedirectToAction("TreventLookUp");
        }
    
        public ActionResult TreventLookUp()
        {
            return View("TreventLookUp");
        }
    }
    

    // View Logic

        @model MvcApplication2.Models.TreventModel
    
    
    Trevent Location Lookup Detail
    Acquiring Institution Identification Code: @**@ @Html.TextBoxFor(m=>m.AcquiringInstitutionIdentificationCode , new {maxlength="200"})
    Card Acceptor Identification Code: @**@ @Html.TextBoxFor(m => m.CardAcceptorIdentificationCode, new { maxlength = "200" })
    Merchant Id: @* *@ @Html.TextBoxFor(m => m.MerchantId, new { maxlength = "200" })

    Add Cancel
    //View Model public class TreventModel { public string AcquiringInstitutionIdentificationCode { get; set; } public string CardAcceptorIdentificationCode { get; set; } public string MerchantId { get; set; } }

提交回复
热议问题