将数据从Html.EditorFor传递到控制器 [英] Pass data from Html.EditorFor to controller
本文介绍了将数据从Html.EditorFor传递到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何将Html.EditorFor中的数据传递给myController中的myAction?
这是我的编辑器:
Hi all,
How do i pass data from a Html.EditorFor to myAction in myController?
This is my Editor:
<div class="editor-label">
@Html.LabelFor(model => model.Quote_Currency)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Quote_Currency, new { })
@Html.ValidationMessageFor(model => model.Quote_Currency)
</div>
这是我的控制器动作:
This is my controller action:
public ActionResult SaveQuote(FxQuote quote, string Quote_Currency)
{
objQuote.Quote_Currency = Quote_Currency;
dcfx.FxQuotes.InsertOnSubmit(quote);
dcfx.SubmitChanges();
return View();
}
在这里,我试图使用一个与我的编辑器同名的参数,但这不起作用.
请帮忙.
Here, I was trying to have a parameter with the same name as my Editor but that did not work.
Please help.
推荐答案
语法错误.没有类似的内容:
Wrong syntax. There is nothing like:
@Html.EditorFor(model => model.Quote_Currency, new {...})
编辑器需要一个表达式而不是多个表达式.
Editor needs one expression and not multiple.
这篇关于将数据从Html.EditorFor传递到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文