I want in the UI that the user enter a number inside a textbox and then show him in the same page using AJAX a record of all the artists with age less than the number the user entered. My doubt is that I don't know how to pass the number entered into the textbox using Ajax to the PartialViewResult method inside my Controller Class
Controller class:
public PartialViewResult GetByAgeLessThan(int age)
{
List<Artist> list = ope.ArtistLessThanAge(age);
return PartialView("GetByAgeLessThan", list);
}
This is my Artists index view(I want to show the results in it using Ajax). My big doubt is in here.. what should I do to pass the number entered inside the textbox to my PartialViewResult inside my controller??? There should be something wrong in this code... when I press the submit button nothing happens:
@using (Ajax.BeginForm("GetByAgeLessThan", "Artists", new AjaxOptions()
{
HttpMethod = "GET",
UpdateTargetId = "divajax",
InsertionMode = InsertionMode.Replace
})){
<h4>Search</h4>
@Html.TextBox("txtAge")
<input type="submit" name="Command" value="Search"/>
}
return PartialView("GetByAgeLessThan", new MyPartialViewModel { Age = age, List = list})