在事件上调用多个 javascript 函数
我正在使用 ajaxcontroltoolkit 并尝试在选项卡更改事件上调用几个函数。
我想从 OnClientActiveTabChanged 函数调用多个 js 函数,但不断收到错误
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
更新,我刚刚注意到即使对于基本警报语句也会发生这种情况。
OnClientActiveTabChanged="alert('testone');alert('testtwo');"
给出问题的行:
Sys.Application.add_init(
function()
{
$create(AjaxControlToolkit.TabContainer,
{
"activeTabIndex":0,
"clientStateField":$get("ctrlJobPropertiesView_tbcTabContainer_ClientState")
},
{
"activeTabChanged":alert('testone');alert('testtwo');
},
null,
$get("ctrlJobPropertiesView_tbcTabContainer")
);
});
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")
);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
盲目射击:尝试将其包装在匿名函数中,例如:
编辑:我的解决了问题,gs 是最完整的。
Blind shot: try to wrap it in an anonymous function, like:
EDIT: mine solves the problem, gs's is the most complete.
这是你的问题:
我猜你想要的是
activeTabChanged
是一个函数,但alert("something")
不返回函数,但什么也不返回。字典中的分号在语法上是错误的。您想要将函数分配给
activeTabChanged
:您不需要使用匿名函数。您也可以使用常规的。
Here's your problem:
I guess what you want is that
activeTabChanged
is a function, butalert("something")
doesn't return a function but nothing.The semicolons is syntactically wrong in a dictionary. You want to assign a function to
activeTabChanged
:You don't need to use anonymous functions. You can also use regular ones.
将它们放在引号中
Put them in quotes
尝试使用这个:
Try using this: