At the moment I have a MasterPage in an ASP.NET MVC3 project with a animesearch function
function AnimeSearch() {
alert(document.getElementById('anime').value);
window.location = "Paging/AnimeBySearch?searchstring=" + (document.getElementById('anime').value);
}
What I do , I type in an anime movie in an html input tag and it returns the correct values accordingly.
As one can see , is that my JavaScript function is calling my controller and then the function with the correct parameters(from the input).
However a couple of questions.
First since this function is on my masterpage and the controller call is pretty static the following of course happens. When I get my result after for instance searching for "naruto" I am in the paging controller. If I want another anime movie then of course because of my static location the controller does not work anymore. This is my first question , what is the cleanest and proper way of handling this(no hacks please , did that , works but is not good coding )?
Second Is my approach correct ( calling the controller and action like this from javascript )?