在@ html.actionlink传递多个参数() [英] passing multiple parameters in @html.actionlink()

查看:1577
本文介绍了在@ html.actionlink传递多个参数()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ActionLink的传递参数​​code按钮控制器项目,并得到细节上的新观点(实际上,它的控制器调用3部分景观)

I'm using actionlink to pass parameter "code" to controller for an item and get details for that item on new view (actually, it's controller that calls 3 partial views)

我还需要传递参数说明但是这只是需要被显示为新的观点,并在控制器没有用(我用code来过滤数据库记录)的值。

I also need to pass parameter "description" but that's just an value that need to be shown as on new view and has no use in controller (i'm using "code" to filter database records).

@foreach (var item in Model.MyModel)
{
  <tr>
    <td>
      @Html.ActionLink(item.code, "Index", "ControlerName", new { pos = item.code.ToString(), desc = item.desc.ToString() }, null)
</td>


    }

}

这ActionLink的给我的网址/ ControlerName POS = code和; DESC =降序

this actionlink give me url /ControlerName?pos=code&desc=desc

有没有办法送递减参数,这样就不会在网址中看到,但只显示在新的看法呢?

Is there a way to send "desc" parameter so it won't be seen in url but only shown as in new view?

推荐答案

没有,Html.ActionLink的存在只是为了生成一个URL和放下它锚标签内。当它击中你应该再植从索引行动递减值。

No, Html.ActionLink only exists to generate a url and plop it inside an anchor tag. You should be repopulating the desc value from your Index action when it's hit.

这篇关于在@ html.actionlink传递多个参数()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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