I don’t find how to submit a form that’s in a partial view.
I’ve made a kind of search engine for a website. I’d like to add it in the layout from a partial view. My problem is that when I click on ‘submit’, nothing happens if I’m not in the search view.
Here is the code of the partial view
@Using Html.BeginForm(IsPost)
@Html.TextBox("SearchString")
@<input type="submit" value="Go!"/>
End Using
How should I parameter my button if I want it to work correctly?
Namespace MvcApplication4
Public Class SearchController
Inherits System.Web.Mvc.Controller
Private db As schema_crmEntities = New schema_crmEntities
'
' GET: /Search
Function Index() As ActionResult
Return View()
End Function
'
' POST: /Search
<HttpPost()>
Function Index(search As String) As ActionResult
Dim chaine As String = Request("searchString")
[...]
Dim model = New SearchModel With {
.Meetings = meetings,
.Interviews = interviews,
.Opportunites = opportunites,
.Clients = clients,
.Contacts = contacts
}
Return View(model)
End Function
End Class
End Namespace
;
<form method="post" action="/(S(v1sax2fo0frbeuw1ul1xcoet))/Search"><input type="text" value="" name="SearchString" id="SearchString"/>
<input type="submit" value="Go!"/>
</form>
Make sure you specify the controller and the action you are posting to: