在组合框值上执行客户端事件更改为填充其他标签

时间:2013-11-17 08:39:12

标签: asp.net-mvc asp.net-mvc-4 devexpress

我正在研究mvc4项目。我有一个devexpress组合框。我想根据comboxbox值在客户端获取其他文本框中的值。

我指的是这个例子

http://www.devexpress.com/Support/Center/Question/Details/Q360473

但我不知道如何实现这个目标

这是我的组合框绑定的部分视图代码

@Html.DevExpress().ComboBox(
    settings => {
        settings.Name = "comboBoxGetUsersByEmail";
        settings.Width = 250;
        settings.SelectedIndex = 0;
        settings.Properties.DropDownWidth = 550;
        settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
        settings.CallbackRouteValues = new { Controller = "ManageUsers", Action = "GetEmployeesByEmail" };
        settings.Properties.CallbackPageSize = 20;
        settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
        settings.Properties.TextFormatString = "{0}";
        settings.Properties.ValueField = "email";
        settings.Properties.ValueType = typeof(string);

        settings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e) { OnEmailChange(); }";

        settings.Properties.Columns.Add("email", "Email", 120);
        settings.Properties.Columns.Add("employeeid", "EmployeeID", 40);
        settings.Properties.Columns.Add("name", "Name", 130);
    }
).BindList(ViewData["Employees"]).GetHtml()

现在我想要当combox更改的值我在页面中有mvc帮助标签时所以在更改combox值时,它们会根据其值填充

1 个答案:

答案 0 :(得分:1)

这很好, 在您的javascript函数中添加以下代码:

<script>

 function OnEmailChange(){
 var selectedValue = comboBoxGetUsersByEmail.GetValue();
 document.getElementById('YOUR_LABEL_ID').innerHTML = selectedValue;
 }
</script>