asp.net mvc select change redirect to Action
- by mazhar kaunain baig
I am correctly passing the action name from the Controller to the paging class and then using select list i want to redirect to that action. at this moment it is appending to the current url.i want the correct way of redirecting to the controller action manageUser using select list below
What should we have here in Model.COntroller . ControllerName/ActionName/ or Just ActionName
<select id="paging" onchange="location.href='<%= Model.Controller %>'+this.value">
<% for (int i = 1; i <= Model.TotalPages; i++)
{ %>
<option id=<%=i %>><%=i %></option>
<% } %>
</select>
public class PaginatedList<T> : List<T>
{
public string Controller { get; private set; }
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize,string Cont)
{
Controller = Cont; // here is the controller
}
}
Controller
public ActionResult ManageUser(int? page)
{
const int pageSize = 5;
var AllUser = UserRepository.GetAllUser();
var paginatedUsers = new PaginatedList<Users>(AllUser, page ?? 1, pageSize,"ManageUser/Page/");
return View(paginatedUsers);
}