asp.net mvc view user control for data capturing
I am tring to add a user control to do a search. 开发者_C百科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){
}
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
精彩评论