Redirect with several url parameters



  • model

    public class Filter
    {
        public string id { get { return _id; } set { _id = value; } }
        public string date { get; set; }
        public string type { get; set; }
        private string _id = "all";
    }
    

    Controller

    public ActionResult Detail(Filter fltr) {
        List<SelectListItem> ddl = new List<SelectListItem>();
        /*.....*/
        ViewBag.date = ddl; //
        ViewBag.filter = fltr;
        return View();
    }
    

    http://baseurl/contr/detail/all?date=2015-11-11&type=dynamic

    On the page. @html.DropDownList("date", null, new { @class = "my-class"})

    How do you do if there's a change on exchange at dropdownlist the date in url and redirected using the filter model?



  • Here we go.

    $('#date').on('change', function(){
       var val = $(this).val();
       $(location).attr('href', 'http://baseurl/contr/detail/all?date='+val+'&type=dynamic');
    });
    

    UPD: The answer does not consider the TC &apos; s wish to send the model through querystring GET of the request


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2