views:

12

answers:

1

I am tring to add a user control to do a search. this user control is to be used on the home page and for example /category-page.

where do I write the code for data capturing. is there a way to force the user control to submit to a HomeController or the controller I want?

I hope my question is clear.

I have the following on the homecontroller which will work but I dont want to duplicate this on another controller.

 [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Search(string key){

    }
+1  A: 

The user control should have a element that would post to your controller like this:

<% using(Html.BeginForm("Search", "Home")) { %>
    <input type="text" name="key" />
    <input type="submit" />
<% } %>

Check here for more information Rendering a Form in ASP.NET MVC Using HTML Helpers

adriaanp
just found it myself. but thanks a lot for a speedy answer.
muditha