简体   繁体   English

将数据从JQuery传递到MVC3控制器

[英]Passing Data from JQuery To MVC3 Controller

i have a requirement where am doing search based on the users input and users can dynamically add the search row 我有一个根据用户输入进行搜索的要求,用户可以动态添加搜索行

<tr id="tblNewContentRow">
<td>
@Html.TextBox("txtNewAttributes", "", new { @class = "alphaonly", style = "width: 155px;" })
</td>
<td>
@{@Html.DropDownList("ddlNewValues", Model.OperandsMaxList, new { style = "height: 20px;" })
}
</td>
<td colspan="2">
@Html.TextBox("txtNewValues", "", new { @class = "numbersonly", style = "width: 250px;" })
 </td>
</tr>

and ADD button generates the similar row below this row dynamically(i used Jquery) as much rows as user wants. 和ADD按钮会在该行下方动态生成类似的行(我使用了Jquery),可以根据用户需要生成尽可能多的行。

When the user hits submit i want to query this attributes(textbox,dropdown,textbox) for list in Database. 当用户点击提交时,我想查询该属性(文本框,下拉列表,文本框)以获取数据库中的列表。 i can pass this data using the Ajax call. 我可以使用Ajax调用传递此数据。

My question is how to send those multiple values in json to controller so ican easily map and retrieve values 我的问题是如何将json中的多个值发送到控制器,以便我可以轻松地映射和检索值

var data=('#form_id').serializeArray(); var data =('#form_id')。serializeArray();

Then send this ' data' as attribute and expect string[] type in controller. 然后将此“数据”作为属性发送,并期望在控制器中使用string []类型。 The whole data will be passed to the controller 整个数据将被传递到控制器

Cheers PHANI* 干杯PHANI *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM