3
I am new to ASP.NET and am creating an MVC application. I have in my controller a method that works as follows:
public ActionResult ShowClients(string proc)
{
--(proc)EXECUTA ALGUMA LOGICA AQUI
return View();
}
The logic of this method has already been tested and is working perfectly, the problem is that I need to pass this string "proc" to this controller through a form that is in the view (in this case it would be the parameter that the user would type). Then, when the user filled the textbox and clicked the Submit button the method would be called with what was written in the textbox. With the code below, I was able to send the parameter to the method but the problem is that besides the @url. Action being a GET method, I also can’t insert variables in it (at least not that I know):
<form method="post">
<input type="text" id="NICK" name="proc" placeholder="Digite Nome ou CPF">
<input type="submit" onclick="parent.location='@Url.Action("ShowClients", "Clientes", new { proc = "SAUL DOM" })';return false;" value="Pesquisar" >
</form>
Is there any way to do this?
You can send this data through Razor or JS Ajax, as to put parameters for Get methods, you can put yes, if we could never query to return only one entity per ID
– Paz