Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>What is the Problem in Existing code ?</strong></p> <p><em>There is no Input Type Text Control in the form and that's the reason information is not being sent to server. TextBox like controls forwards the data for sending the information to Controller Action Method.</em></p> <p><strong>Corrective Action</strong></p> <p><em>Let's say TextBox is not Required in you case. Then, you can place <code>Hidden Fields</code> for those <strong>View Model</strong> Properties which are required to be sent to Controller Post Action method.</em></p> <p><em>Example</em></p> <pre><code>@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post)) { &lt;fieldset class="fs"&gt; @foreach (var item in Model.lstTravelReadyEntities) { &lt;label class="Detail1"&gt; &lt;b&gt;Associate Id : &lt;/b&gt;@item.Var_AssoId &lt;/label&gt; @Html.HiddenFor(i=&gt; item.Var_AssoId) //Added Hidden Field to send this to server &lt;label class="Detail1"&gt; &lt;b&gt;Vertical :&lt;/b&gt;@item.Var_Vertical&lt;/label&gt; @Html.HiddenFor(i =&gt; item.Var_Vertical) //When post this Hidden Field will send &lt;label class="Detail1"&gt; &lt;b&gt;Visa ValidFrom :&lt;/b&gt;@item.Dt_VisaValidFrom &lt;/label&gt; @Html.HiddenFor(i =&gt; item.Dt_VisaValidFrom) &lt;br /&gt; } &lt;h2&gt; Response Details&lt;/h2&gt; &lt;br /&gt; &lt;/fieldset&gt; } </code></pre> <p><em>For explaining point of view, I excluded some of the controls. Now, You can add Hidden Fields for those Properties which are required to be sent to Action Method.</em></p> <p>Also you should use View Models instead of Passing Individual parameter to Action Method.</p> <p>Hope this will help you.</p>
 

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