开发者

Got to Get the value to the controller

<div> <% foreach (var item in Model)
         { %>


          <div class="editor-label">
            <%: Html.LabelFor(model =>item.Customer) %>
             <%: Html.Encode(item.Customer) %>
        </div>

         <%break; %>

         <%} %></div>
         <p></p>

          <input id="Submit1" type="submit" value="Create New"  />

Need the value in item.Customer to be sent To 开发者_运维问答the Controller Through the "Create New Button"


You should be able to put the value in a hidden form field and then add that field as a parameter to the controller action to which the form posts.


First, make sure you start a form that submits the appropriate controller/action. Second, store the value in a hidden field (via the HiddenFor extension method):

<% using(Html.BeginForm("YourAction","YourController)) { %>
    <div>
        <% foreach(var item in Model){ %>
            <div class="editor-label">
                <%= Html.LabelFor(model => item.Customer) %>
                <%= Html.HiddenFor(model => item.Customer %>
            </div>
        <% } %>
        <p></p>
        <input id="Submit1" type="submit" value="Create New" />
    </div>
<% } %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜