1

I'm using the ajaxcontroltoolkit and trying to call a couple of functions on a tab changed event.

I want to call more than one js function from my OnClientActiveTabChanged function but keep getting the error

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR      1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET     CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Tue, 24 Nov 2009 12:31:43 UTC


Message: Expected '}'
Line: 202
Char: 181
Code: 0
URI: http://localhost/.../.../....aspx?ID=1000&propertyFrameWidth=1234&propertyFrameHeight=603&userId=9&employeeId=526&CCId=2&DbConnTag=TSDBConnection

Update, I've just noticed this happens even for basic alert statements..

OnClientActiveTabChanged="alert('testone');alert('testtwo');"

Line giving the problem:

Sys.Application.add_init(
function() 
{
    $create(AjaxControlToolkit.TabContainer, 
            {
             "activeTabIndex":0, 
             "clientStateField":$get("ctrlJobPropertiesView_tbcTabContainer_ClientState")
            },
            {
             "activeTabChanged":alert('testone');alert('testtwo');
            },
            null, 
            $get("ctrlJobPropertiesView_tbcTabContainer")
        );
});
Amarghosh
  • 58,710
  • 11
  • 92
  • 121
user48408
  • 3,234
  • 11
  • 39
  • 59

4 Answers4

3

Blind shot: try to wrap it in an anonymous function, like:

"activeTabChanged":function() { alert('testone');alert('testtwo'); }

EDIT: mine solves the problem, gs's is the most complete.

Community
  • 1
  • 1
Alex Bagnolini
  • 21,990
  • 3
  • 41
  • 41
0

Try using this:

function callMultiple() {
   func1();
   func2();
   func3();
}

OnClientActiveTabChanged="callMultiple"
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
Naveed Butt
  • 2,861
  • 6
  • 32
  • 55
0

Here's your problem:

{"activeTabChanged":alert('testone');alert('testtwo');}

I guess what you want is that activeTabChanged is a function, but alert("something") doesn't return a function but nothing.

The semicolons is syntactically wrong in a dictionary. You want to assign a function to activeTabChanged:

"activeTabChanged":function() { alert("testone"); alert("testtwo"); }

You don't need to use anonymous functions. You can also use regular ones.

function on_activeTabChanged() {
     // do something
}

// much later in the code
$create(AjaxControlToolkit.TabContainer,
        {"activeTabChanged":on_activeTabChanged});
Georg Schölly
  • 124,188
  • 49
  • 220
  • 267
0

Put them in quotes

"activeTabChanged":"alert('testone');alert('testtwo')";
Amarghosh
  • 58,710
  • 11
  • 92
  • 121