0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.