.net mvc2 Html.RenderAction 如何传递参数?

suncheng_hong 2010-08-31 04:52:11
<div id="tabs-3">
<% Html.RenderAction("notice_add", "admin");%>
</div>
可以加载action,但我需要传递一个参数过去,形如 http://localhost:3528/admin/notice_add/1如何把1传递过去呢?
查了文档,
//
// 摘要:
// Invokes the specified child action method using the specified parameters
// and controller name and renders the result inline in the parent view.
//
// 参数:
// htmlHelper:
// The HTML helper instance that this method extends.
//
// actionName:
// The name of the child action method to invoke.
//
// controllerName:
// The name of the controller that contains the action method.
//
// routeValues:
// An object that contains the parameters for a route. You can use routeValues
// to provide the parameters that are bound to the action method parameters.
// The routeValues parameter is merged with the original route values and overrides
// them.
//
// 异常:
// System.ArgumentNullException:
// The htmlHelper parameter is null.
//
// System.ArgumentException:
// The actionName parameter is null or empty.
//
// System.InvalidOperationException:
// The required virtual path data cannot be found.
public static void RenderAction(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues);

routeValues 如何传?
我尝试: <% Html.RenderAction("notice_add", "admin","1");%>
但1并没有传入到action中,请问如何解决?
另外asp.net mvc api,在哪里,没有找到哦。
...全文
1292 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qwerqwer6 2011-11-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 fanjingfeng 的回复:]

应该要怎么调用呢
[/Quote]
public ActionResult Act123(int id) //注意:这里参数要叫作id
{...}
fanjingfeng 2010-09-13
  • 打赏
  • 举报
回复
应该要怎么调用呢
尐孑 2010-08-31
  • 打赏
  • 举报
回复
收藏
suncheng_hong 2010-08-31
  • 打赏
  • 举报
回复
解决了。
<% Html.RenderAction("notice_add", "admin", new { id="1"});%>
object 竟然这样生成对象,这是什么语法?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧