从MVC3查看传递多个值的ActionMethod [英] Passing multiple value from MVC3 View to an ActionMethod
本文介绍了从MVC3查看传递多个值的ActionMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道是否有人能帮助我在这里。我的声音听起来有点像一个thicko道歉,但我是新来的MVC3,我试图从一个视图传递2值的操作方法,但它只是是不是在玩公平!
I wonder if anybody can help me here. I apologise for sounding like a thicko but I'm new to MVC3 and I'm trying to pass 2 values from a view to an action method but it just isn't playing fair!
HTML
@Html.ActionLink("ASSIGN", "AssignTokenToDataTemplate", "HostHtmlTokenManager",
new { htmlTokenId = item.Id }, new { htmlDataTemplateId = 1 })
操作方法:
public ActionResult AssignTokenToDataTemplate(int htmlTokenId, int htmlDataTemplateId)
{
// Do some database stuff here
return View("AssignAnExistingTokenToHtmlDataTemplate", new {templateId = htmlDataTemplateId});
}
我要两个整数传递到AssignTokenToDataTemplate操作方法,但我无法得到它的工作?!
I want to pass two integers into the AssignTokenToDataTemplate action method but I cannot get it to work?!
任何人都可以看到我要去哪里错了吗? (
Can anybody see where I'm going wrong? :(
推荐答案
您使用 routeValues
参数可以通过这两个值:
You could pass both values using the routeValues
parameter:
@Html.ActionLink(
"ASSIGN", // linkText
"AssignTokenToDataTemplate", // actionName
"HostHtmlTokenManager", // controllerName
new { // routeValues
htmlTokenId = item.Id,
htmlDataTemplateId = 1
},
null // htmlAttributes
)
这篇关于从MVC3查看传递多个值的ActionMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文