Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to obtain data from a form using method="post"? How to request it data in my controller?
    primarykey
    data
    text
    <p>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. I know its request.form. I believe im doing it wrong. Is there an easier way for me to pass the object or each name as a parameter through the function?</p> <p>Html</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $("#SavetreventLocationLookupAddButton").click(function () { $("#addSaveTreventLocationLookup").submit(); }); }); </code></pre> <p></p> <h2>Add Trevent Location Lookup</h2> <pre><code>&lt;form id="addSaveTreventLocationLookup" method="post" action="&lt;%: Url.Action("AddSaveTreventLocationLookup","Prod") %&gt;"&gt; &lt;table&gt; &lt;tr&gt; &lt;td colspan="3" class="tableHeader"&gt;Trevent Location Lookup Detail&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" class="label"&gt;Acquiring Institution Identification Code:&lt;/td&gt; &lt;td class="content"&gt; &lt;input type="text" maxlength="200" name="AcquiringInstitutionIdentificationCode" id="AcquiringInstitutionIdentificationCode" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" class="label"&gt;Card Acceptor Identification Code:&lt;/td&gt; &lt;td class="content"&gt; &lt;input type="text" maxlength="200" name="CardAcceptorIdentificationCode" id="CardAcceptorIdentificationCode" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" class="label"&gt;Merchant Id:&lt;/td&gt; &lt;td class="content"&gt; &lt;input type="text" maxlength="200" name="MerchantId" id="MerchantId" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="tableFooter"&gt; &lt;br /&gt; &lt;a id ="SavetreventLocationLookupAddButton" href="#" class="regularButton"&gt;Add&lt;/a&gt; &lt;a href="javascript:history.back()" class="regularButton"&gt;Cancel&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>Contoller</p> <pre><code>[HttpPost] [AuthorizeAttribute(AdminRoles = "AddTreventLocationLookup")] public ActionResult AddSaveTreventLocationLookup() { try { string acquiringInstitutionIdentificationCode; //= Request.Form["AcquiringInstitutionIdentificationCode"] ?? string.Empty; string cardAcceptorIdentificationCode;// =/Request["CardAcceptorIdentificationCode"] ?? string.Empty; string merchantId;// = Request["MerchantID"] ?? string.Empty; if (!string.IsNullOrEmpty(Request.Form["AcquiringInstitutionIdentificationCode"])) { acquiringInstitutionIdentificationCode = Request.Form["AcquiringInstitutionIdentificationCode"]; } if (!string.IsNullOrEmpty(Request.Form["CardAcceptorIdentificationCode"])) { cardAcceptorIdentificationCode = Request.Form["CardAcceptorIdentificationCode"]; } if (!string.IsNullOrEmpty(Request.Form["MerchantID"])) { merchantId = Request.Form["MerchantID"]; } AdminProductionServices.TreventLocationLookup treventLocationLookup = Administrator.Models.AdminProduction.TreventLocationLookup.loadTreventLocationLookup(Guid.Empty, Guid.Empty, string.Empty, string.Empty, string.Empty)[0]; treventLocationLookup.acquiringInstitutionIdentifcationCode = acquiringInstitutionIdentificationCode; treventLocationLookup.cardAcceptorIdentificationCode = cardAcceptorIdentificationCode; treventLocationLookup.merchantId = merchantId; Administrator.Models.AdminProduction.TreventLocationLookup.addTreventLocationLookup(treventLocationLookup); } catch(Exception e) { Commons.ErrorHandling.ReportError("Administrator.Controller.ProdController AddSaveTreventLocationLookup()", e); } return RedirectToAction("SearchTreventLocationLookup", "Prod"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload