Asp.net mvc send parameter to action with submit button in the partialView

你离开我真会死。 提交于 2021-01-29 16:53:06

问题


My partialView is Opened in the modal dialog form, User select special row, I want to Submit the parent form with special value as a parameter.

My parent form is:

<form id="mainForm" action="<%= Request.RawUrl %>" method="post" enctype="multipart/form-data">

and my submit button in the modal dialog (and in the GridView) that post data to action is:

<button name="selectVehicle" id="<%= item.id %>" value="selection" type="button" onclick="$('#mainForm').submit()">
                    OK
                </button>

this is work correctly and all my data Post to the Action, but how can i send special Value to the action using this submit button?


回答1:


Add a hidden field, and update the value in the onclick handler.



来源:https://stackoverflow.com/questions/1700446/asp-net-mvc-send-parameter-to-action-with-submit-button-in-the-partialview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!