如何访问我的FormCollection的操作方法ASP.NET MVC? [英] How to access my formcollection in action method ASP.NET mvc ?

查看:351
本文介绍了如何访问我的FormCollection的操作方法ASP.NET MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有形式集合中的操作方法访问,但如何得到它的价值。我试过这样

I have form collection accessed in action method ,but how to get the value of it .I tried like this

string value = collection[1];

但我可以。如何在行动方法访问的价值,我没有得到的值。

but I am not getting the value .How can I access the value in action method.

推荐答案

如果您有:

<input type="text" name="inputName" />

您可以使用属性名的元素象下面这样:

You could use the attribute name of the element like below:

[HttpPost]
public ActionResult yourAction(FormCollection collection)
{
     string value = Convert.ToString(collection["inputName"]);
     ...
     return View();
}    

这篇关于如何访问我的FormCollection的操作方法ASP.NET MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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