Hello there, this might be a novice question. But here we go anyway.
The searchpage works as intented, but when the searchQuery is submitted, I need the the controller to do the search "onpageload" if the querystring contains the "SearchWord" - right now, the user needs to click the search button to activate the controller.
I have the following files
\Views\MacroPartials\search_input
---------------
@inherits Umbraco.Web.Macros.PartialViewMacroPage <div class="search-input"> <div class="search-title hidden-xs"> <span>Velkommen!</span> - Hvad kan vi hjælpe med i dag ? </div> <form action="/soegning.aspx" method="GET"> <div class="search-field"> <input type="submit" value="Søg" /> <input type="text" name="SearchWord" id="SearchWord" placeholder="Hvad kan vi hjælpe med?" /> </div> </form> </div>
I don't think you can achieve that with your approach, because the SearchPage action doesn't execute unless the form is POSTed.
You can simplify everything by putting the code from the SearchPage action in the SoegSide view, where you can check for Request["SearchWord"]. Not that elegant, but it works well. You won't need a PageSearchModel anymore, and the PageSearch partial is not necessarily needed, you can have everything in the SoegSide view.
Alternatively, you can implement a custom controller that hijacks the Umbraco route for the search page.
MVC "onpageload"
Hello there, this might be a novice question. But here we go anyway.
The searchpage works as intented, but when the searchQuery is submitted, I need the the controller to do the search "onpageload" if the querystring contains the "SearchWord" - right now, the user needs to click the search button to activate the controller.
I have the following files
\Views\MacroPartials\search_input
---------------
\Views\MacroPartials\PageSearch
---------------
\Views\SoegSide
----------
\Models\PageSearchModel
---------------
\Controllers\PageSearchController
-------------------
Hi Lasse,
I don't think you can achieve that with your approach, because the SearchPage action doesn't execute unless the form is POSTed.
You can simplify everything by putting the code from the SearchPage action in the SoegSide view, where you can check for Request["SearchWord"]. Not that elegant, but it works well. You won't need a PageSearchModel anymore, and the PageSearch partial is not necessarily needed, you can have everything in the SoegSide view.
Alternatively, you can implement a custom controller that hijacks the Umbraco route for the search page.
Hi Lasse,
I think what you need to do is hijack the route of your doctype take a look here
http://our.umbraco.org/documentation/Reference/Mvc/custom-controllers
If you dont need this then call the method in your view, set the result in a model property and then pass that to your partial view?
Make sense?
Charlie :)
is working on a reply...