I have two kendo windows in a page(add and edit), both having the dropdownlist with same name.
@(Html.Kendo().DropDownList()
.Name("TypeId")
.DataTextField("TypeName")
.DataValueField("Id")
.datasource(source =>
{
source.Read(read =>
{
read.Action("Action", "Controller");
})
}))
When accessing the add window the dropdown looks good, then open and close the add window for three times and then access the edit window.
the second time I access the edit window the dropdownlist disappears, then a textbox appears in place of dropdownlist.
When I use MVC4 dropdownlist control there is no problem, the problem is only with kendo dropdownlist.
Can anyone advice what I am doing wrong.
You cannot have multiple widgets with the same name – you need to ensure that each widget has unique name.
Behind the scenes you assign name to the widget via the Name method – it assign’s an ID to the html wrapping element which is used to find the widget and initialize it. As you might know if you have two html elements with the same id – jQuery will return always the first one and because of this the second widget will not be initialized and will remain as regular textbox input.