DropDownList Change Event Load Grid Data

2 posts, 0 answers
  1. Ajay
    Ajay avatar
    5 posts
    Member since:
    Sep 2014

    Posted 07 Oct 2014 Link to this post

    In one of my pages I am trying to load data when DropDown
    Value is changed. However I have hard time in call contoller’s action method on
    dropdown’s onchange event. If you have any sample available please share with
    me.

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 09 Oct 2014 Link to this post

    Hello Ajay,

    I suppose that you've wired the widget change event (via the Change method) to detect whether the value has been changed. In this event handler you can use $.ajax to call the Action method in question:

    [cshtml]:
    @(Html.Kendo().DropDownList()
           .Name("name")
           ...
           .Events(e => e.Change("ddl_change"))
           ...
    )

    [JavaScript]:
    function ddl_change(e) {
       var widget = e.sender;
       var value = widget.value();
     
       $.ajax({
          url: "Action url",
          data: { ddlValue: value },
          success: function(data) {
              //do what you need here
          }
       })
    }
    Here is a tutorial, which popped out after a quick Google search, that explains different ways to call Controller Action method.

    Regards,
    Georgi Krustev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top