2017-07-02 30 views
-1

我有这个MVC控制 这是我的控制obout 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()功能时,选择指数变化

+0

为什么你需要组合框我没有得到你的问题。 –

+0

@LaxmanGite我需要使用这个组合框控件,需要调用改变了这个组合框 –

回答

0

documentation of obout它说,该函数将有两个输入paramters即senderselectedIndex,根据你的函数定义应该是这样的:

function checkalert(sender, selectedIndex) { 
    debugger; 
    alert(" change"); 
return '1'; 
} 

并且如果您在剃刀代码后有脚本查看,那么你需要把JavaScript代码放在视图之上。

你可以看到提供Obout网站here代码工作的例子。

并且还删除ClientSideEvents setter之后定义的其他SelectedIndexChanged事件,因为您只需要客户端事件,这也会导致错误。

希望它可以帮助您解决问题。

+0

的JavaScript运行时错误对指数的另一个功能:“checkalert”是不确定的也是你去哪里定义的js函数 –

+0

? –

+0

在脚本标记 –

相关问题