如何在控制器中获取隐藏字段值? [英] How to get hidden field value in controller?

查看:79
本文介绍了如何在控制器中获取隐藏字段值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    尝试       代码   i   am   能够  to   get     value 

查看
< input type =hiddenid =hiddenTabname =hiddenTabvalue =10/>

controler
string currentHiddenvalue = 请求 .FORM [ hiddenTab];


it 可能 提供 guid to hidden field layout

解决方案

< blockquote>表单的所有文件都是在POST上提交的,对类型无关,因此也是隐藏的。如果该字段是POST正文的一部分,请检查您的http流量以查看。在IE10 +或Chrome中使用Fiddler或网络检查员。 Firefox还有一个检查器作为加载项。它应该在那里,如果没有,你的HTML表单无效。在控制器端,您最好通过添加必要的操作方法参数或模型绑定来使用映射。尽管如此,这也有效 [ ^ ]。但不是在控制器构造函数中!

只需调试你的动作方法,看看Request变量中有什么。


I have tried with the below code but i am not able to get that value.

In View
<input type="hidden" id="hiddenTab" name="hiddenTab" value="10" />

In controler
string currentHiddenvalue = Request.Form["hiddenTab"];


Is it possible to provide guid to hidden field in layout.

解决方案

All fileds of a form are submitted on POST, indifferent of the type, thus also the hidden ones. Check your http traffic to see, if the field is part of the POST body. Use Fiddler or the network inspectors in IE10+ or Chrome. Firefox has also an inspector as add-in. It should be there, if not, your html form is not valid. On controller side you better use mapping by adding the necessary action method parameter, or model binding. Still, this works too[^]. But not in the controller constructor!
And simply debug your action method and see what's in the Request variable.


这篇关于如何在控制器中获取隐藏字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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