如何在mvc 4 razor中点击按钮获取动态文本框值 [英] how to get dynamic textbox values on button click in mvc 4 razor

查看:102
本文介绍了如何在mvc 4 razor中点击按钮获取动态文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用mvc 4 razor中的文本框,复选框,单选按钮创建了动态表单,现在我想在按钮点击后填写表单后获取值,我怎样才能获得值。



这是我的cshtml代码

I have created dynamic form using textbox,checkbox,radio button in mvc 4 razor, Now I want to get values after filled form on button click, How can i get values.

This is my cshtml code

@{foreach (var item in Model)
{
  <input class="form-control " type="@item.ControlName" value="">
}





我想在控制器中接收我的价值





I want to recieve my values in controller

public ActionResult ShowForms()
{
            
}





如果有人知道请帮帮我。

提前致谢..........!



If anyone knows please help me.
Thanks in advance..........!

推荐答案

您的表格需求提交按钮以及与表单本身相关联的操作(帖子)。

一旦点击提交按钮,将调用相应控制器中的操作方法,并将值传递给它。 />


完成实施添加新产品(第2部分 - 第一种方法)这里 [ ^ ]。
Your form needs a submit button and also an action (post) associated to the form itself.
Once you hit the submit button, action method in the corresponding controller will be called and values will be passed to it.

Go through "Implementing Add New Product (Part 2 - First Approach)" here[^].


这篇关于如何在mvc 4 razor中点击按钮获取动态文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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