I've a webpage which contains 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 a js function which at the moment does nothing.
<script type="text/javascript">
function ChangeTab()
{
alert('Sucesss');
}
</script>
In my page load in the code behind I create a couple of tab panels and add them to the container. Now, my problem is that when i change tab, the javascript alert box shows but once i close it i get the error
Microsoft JScript runtime error: Sys.InvalidOperationException: Handler must be a function.
You need to remove the parens from the attribute...
Change
OnClientActiveTabChanged="ChangeTab()"
to
OnClientActiveTabChanged="ChangeTab"
Just for clarification when you add the parens it is a literal method call whereas without the parens it is a reference to the method, these assignments work like callbacks expecting a delegate (method reference). Instead it is getting method call and will execute upon original eval (because it is a call) and then fail when attempting to be invoked properly because it is mot an actual method reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With