如何调用从asp.net code javascript函数的背后 [英] How to Call javascript function from asp.net code behind
问题描述
如何从ASP.NET code后面调用JavaScript函数?
How to call JavaScript function from ASP.NET code behind?
我有JavaScript函数,我在 ListView的使用它
带参数
I have JavaScript function and I am using it in a listview
with a parameter
我想在code其他参数背后使用它?
I want to use it with another parameter in code behind ?
<a href="ChatBox.aspx?id=<%# Eval("USR_UserID")%> "
onclick="openWindow(this.href,'chat<%# Eval("USR_UserID")%>',600,600);
this.blur();
return false;"><%# Eval("USR_UserName") %></a>
这是列表视图
的一面。如何使用了OpenWindow
后面脱颖而出特定ID code函数?
that is the listview
side. How can I use openwindow
function in code behind fore specific ID?
推荐答案
我想使用的RegisterClientScriptBlock
将是最好的解决方案。
I would think using RegisterClientScriptBlock
would be the best solution.
假设你有一个JavaScript函数, MyJSFunction()
:
Lets say you have a javascript function, MyJSFunction()
:
function MyJSFunction() {
...
}
在您的事件,如按钮点击,你会注入以下code:
In your event, such as a Button Click, you would inject the following code:
C#:
ScriptManager.RegisterClientScriptBlock(this, typeof(System.Web.UI.Page), "MyJSFunction", "MyJSFunction();", true);
VB.NET:
VB.NET:
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "MyJSFunction", "MyJSFunction();", True)
这有效地插入调用你的JavaScript从code-落后。
This effectively inserts a call to your JavaScript from the code-behind.
这篇关于如何调用从asp.net code javascript函数的背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!