小编Las*_*org的帖子

将参数传递给MVC Ajax.ActionLink

如何将TextBox的值作为ActionLink的参数发送?

我需要使用Html.TextBoxFor

<%= Html.TextBoxFor(m => m.SomeField)%>
<%= Ajax.ActionLink("Link Text", "MyAction", "MyController", new { foo = "I need here the content of the textBox, I mean the 'SomeField' value"}, new AjaxOptions{ UpdateTargetId = "updateTargetId"} )%>
Run Code Online (Sandbox Code Playgroud)

Contoller/Actions看起来像这样:

public class MyController{
   public ActionResult MyAction(string foo)
   {      
      /* return your content */   
   }
}
Run Code Online (Sandbox Code Playgroud)

使用MVC 2.0

parameters asp.net-ajax actionlink asp.net-mvc-2

5
推荐指数
1
解决办法
1万
查看次数