如何将所选值/文本从telerik Kendo自动完成传递到我的控制器?我看到了这些示例,但他们正在访问同一视图中的所选项目,而不是传递给控制器。另外,我使用viewbag作为数据源创建自动完成。 更新:我想在单击提交按钮时访问AccessSelecteditem(txtNames)函数上的选定值。我之所以这样做是因为这种方法适用于html.dropdownlist。
My kendo autocomplete in view.
@using(Html.BeginForm("Index","Home")
@Code
Html.Kendo().AutoComplete() _
.Name("txtNames") _
.DataTextField("Text") _
.BindTo(ViewBag.txtData) _
.Filter("Contains") _
.Suggest(True) _
.MinLength(4) _
.Render()
End Code
End Using
<input type="submit" value="Submit">
Function Index() As ActionResult
‘ Here I am storing the selectitemlist into a viewbag which I used as a datasource for my kendo combobox
ViewBag. txtData = getDataForKendo()
Return View()
End Function
Function AccessSelecteditem(txtNames) As ActionResult
‘ Here I am trying to get the selected value/text value from the kendo comobox.
Dim selectedItem = txtNames.selecteditem
Return View()
End Function