This is a migrated thread and some comments may be shown as answers.

Kendo MVC Dropdownlistboxfor - how to send a post for updating model to the controller

1 Answer 90 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Arul
Top achievements
Rank 1
Arul asked on 05 Nov 2014, 01:58 PM
Hi:
I am new to using Kendo UI. I am using MVC4  (VS 2012) with Kendo Mvc wrappers. I am trying to display a DropdownlistboxFor associated with a model item. Then during listbox change event i want to save that model (in the controller). I have hardcoded listbox items added to the listbox like in the code below. Should i post an ajax call which will call a controller method that saves model? How do i do this ajax post with model data sent to the controller action with the combo box updated data?

Is there any other way?
Thank you so much for your help.

=========================================
My model code is:
public class PackageModelView
    {
        public int DefaultReason { get; set; }
}
=========================================
View code (say named file Package.cshtml) has:
@using .<model namespace directory>
@model PackageModelView

@(Html.Kendo().DropDownListFor(model => model.DefaultAction)
                        .DataTextField("Text")
                        .DataValueField("Value")
                        .BindTo(new List<SelectListItem>()
                        {
                            new SelectListItem()
                            {
                                Text = "Active",
                                Value = "1"
                            },
                            new SelectListItem()
                            {
                                Text = "In-active",
                                Value = "2"
                            }
                        })
                       .Value("1")
                    )


1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 07 Nov 2014, 09:50 AM
Hello Arul,

You should proceed the same way as you would do if you are using a regular form element with select list inside or an ajax form.

http://www.w3schools.com/tags/att_form_action.asp

Or through jQuery:

http://api.jquery.com/submit/

The name attribute of the window is automatically assigned to be the same as the property name that you are going to edit.

Kind Regards,
Petur Subev
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.

 
Tags
TabStrip
Asked by
Arul
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or