Call ActionResult of Another View from form

I am trying to create a search form in my MVC application in View 1. The form was working very well when I used to submit the form to same page (View1). That way I can have two ActionResults - one of which accepts HttpPost requests. Everything is cool here

Now things have become slighly complex and I wish to separate the views. So in View1 there is a form and I wanted the results to be displayed in View2. So how do I call ActionResult of View2 from a form in View1? In short - User enters keyword in View1. Hits Enter. Form in View 1 calls View2. ActionResults in View2 calls some logic to search and return View2 as the view and then I can display the results.

I tried some basic things like action="/View2" but I was pretty sure it would fail. It says 'the resource cannot be found'. Is it even possible to do this? Kindly advice.

*UPDATE*

It can be solved as answered below.

use Html.BeginForm(Name of the ActionResult,Name of the controller)

Answers


You need to specify the URL of the other action in the form, preferably by calling the Html.Form("ActionName", "ControllerName") helper.


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.