Asp.net mvc obout mvc组合框所选索引更改事件不起作用

Asp.net mvc obout mvc组合框所选索引更改事件不起作用,asp.net-mvc,combobox,obout,Asp.net Mvc,Combobox,Obout,我有这个MVC控件 这是我的控制 @Html.Obout(new Obout.Mvc.ComboBox.ComboBox("Country") { SelectedIndex = 0, ShowSelectedImage = true,

我有这个MVC控件 这是我的控制

@Html.Obout(new Obout.Mvc.ComboBox.ComboBox("Country")
                        {
                            SelectedIndex = 0,
                            ShowSelectedImage = true,                                
                            ClientSideEvents = new ComboBoxClientSideEvents()
                            {
                                OnSelectedIndexChanged = "checkalert"
                            },

                         OnSelectedIndexChanged="checkalert",
                            ID = "Country1",
                            FolderStyle = "~/Content/Obout/ComboBox/styles/plain",
                            FilterType = Obout.Mvc.ComboBox.ComboBoxFilterType.Contains,
                            Width = 150,
                            Height = 200,
                            MenuWidth = 640
                        })
这是我的js函数:

function checkalert() {
        debugger;
        alert(" change");
     return '1';
    }
我有个错误

Uncaught ReferenceError: checkalert is not defined
我需要一个
checkalert()
函数,该函数在所选索引从中更改时触发,它表示该函数将有两个输入参数,即
sender
selectedIndex
,根据您的函数定义应该如下所示:

function checkalert(sender, selectedIndex) {
    debugger;
    alert(" change");
 return '1';
}
而且,如果视图中有razor代码之后的脚本,则需要将JavaScript代码放在视图的顶部

您可以在Obot站点上看到工作示例及其提供的代码

并且还删除另一个
SelectedIndexChanged
事件,该事件是在
ClientSideEvents
setter之后定义的,因为您只需要客户端事件,这也会导致错误


希望它能帮助您解决问题。

为什么您需要这个组合框?我没有回答您的问题。@Laxmanite我需要使用这个组合框控件,并且需要在这个组合框的索引上调用另一个函数JavaScript运行时错误:“checkalert”也未定义。您在哪里定义了js函数?在脚本标记的同一视图上错误出现在pageload或更改索引时?请将脚本放在razor代码之前的视图顶部