从 Javascript 调用函数背后的代码
我想从 javascript 调用或触发函数后面的代码。我使用这段代码:
var item = <% fillHistoryGrid() %> ;
但是当我这样写时,我收到错误:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
注意:我的函数后面的代码开始:Public Sub ....
我应该做什么?
I want to call or fire code behind function from javascript. I use this code :
var item = <% fillHistoryGrid() %> ;
but when i write like this, i get error :
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Note : my code behind function starts : Public Sub ....
What should i do ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的模板引擎是什么(ASP、JSP、某些 JavaScript 引擎)?这应该支持这样的要求,语法很可能看起来像 <%= %>
What is the templating engine you are using (ASP, JSP, some JavaScript one)? That should support such requirements, most likely the syntax will look like <%= %>
如果您使用 c#/vb.net 并在 asp.net 中的 javascript 中调用代码隐藏函数
您的函数背后的代码必须是静态的(如果 vb.net 则共享)
并在 javascript 中调用 funname
通过使用
'
if you are using c#/vb.net and calling code-behind function in javascript in asp.net
your code behind function must be static (shared if vb.net)
and call funname in javascript
by using
'