Skip to content

Ajax.BeginForm pass action method parameter

If you have looked at the Ajax.BeginForm() method on ASP.NET MVC Beta 1 you will notice there is no way to specify input parameters to your action as you could do with the lambda extension method Html.BeginForm with Futures.

This is how I got around it:

[sourcecode language='html']

My action method accepting "typeId":

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Add(int? typeId, [Bind(Prefix = "Fields", Include = Name,Description")] Field field)
{ ....... }

So by setting a Hidden form field with your parameter, this passes successfully and is populated as "typeId" within the Add action method.

VN:F [1.9.10_1130]
Rating: 3.0/5 (1 vote cast)
VN:F [1.9.10_1130]
Rating: +1 (from 1 vote)
Ajax.BeginForm pass action method parameter, 3.0 out of 5 based on 1 rating
Bookmark and Share
kick it on DotNetKicks.com
Shout it

NOW, FOR A WORD FROM OUR SPONSORS

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

My name is Graham O'Neale and I'm a software architect from Gold Coast, Australia. I am an overtime thinker, full time coder and awake part time in the real world. I have a keen interest in software development, particularly in the realm of programming (C#, ASP.NET, ASP.NET MVC, LINQ (2 SQL), Entity Framework, Silverlight, Blend, WCF, WPF) and a keen interest in the cutting edge and innovation. I have a new found love for design patterns, ALT.NET practices and well crafted software architecture. The purpose of this blog is to express any thoughts, findings, tips and gripes along my travels in the wonderful world of coding and technology...