Sys.InvalidOperationException: handler must be a function

I have a webpage containing a TabContainer

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
...
....
<form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server"></asp:ScriptManager>
    <cc1:TabContainer runat="server" ID="tbcTabContainer" OnClientActiveTabChanged="ChangeTab()"></cc1:TabContainer>
</form>

which calls the js function, which currently does nothing.

<script  type="text/javascript">
function ChangeTab()
{
    alert('Sucesss');
}
</script>

In my loading page in the code behind, I create a couple of tab bars and add them to the container. Now my problem is that when I change the tab, a javascript warning window appears, but as soon as I close it, I get an error

Microsoft JScript runtime error: Sys.InvalidOperationException: handler must be a function.

+3
source share
2 answers

You need to remove parens from the attribute ...

Change

OnClientActiveTabChanged="ChangeTab()"

to

OnClientActiveTabChanged="ChangeTab"

, , , ( ). eval ( ), , .

+8

, , , "ChangeTab()" "ChangeTab".

, , : ChangeTab (, e)....

+1

Source: https://habr.com/ru/post/1705580/


All Articles