我怎么能得到谁是在ASP.NET MVC的形式定义n次的价值? [英] how i can got the value who are define n times in the form in ASP.NET MVC?

查看:75
本文介绍了我怎么能得到谁是在ASP.NET MVC的形式定义n次的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中用户在使用添加另一个文本框,并填写他们填补了n次一个信息。

i have a form where user fill the n time a information using add another textbox and fill them.

我把他们的名字

textbox_1
textbox_2

现在我怎么能搞到谁是开始textbox_1所有表单值。任何想法做在asp.net mvc的

now how i can got all form values who are start with textbox_1. any idea to do it in asp.net mvc

推荐答案

您可以使用JavaScript获得这个文本框的值,并将其保存在隐藏字段以逗号分隔,然后读取你的操作方法隐藏字段的值(我使用jQuery)

you can get the value of this text box using javascript and save it in hidden field as comma separated then read the hidden field value from your action method(I am using jquery)

var AllTextBoxesInPage = $('input[type=text]');
var AllValues='';
AllTextBoxesInPage.each(function(index){
   if(index==0)
   {
    AllValues+=',';  
   }
   AllValues+=$(this).val();
});
$('#HiddenFieldID').val(AllValues);

在你的控制器类

public ActionResult MyAction(FormCollection MyForm)
{
   String AllValues =MyForm["HiddenFieldName"];
   String[] SeparatedValuse = AllValues.Split(",");
}

这篇关于我怎么能得到谁是在ASP.NET MVC的形式定义n次的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆