如何从asp.net中的javascript调用Codebehind函数? [英] How to call a codebehind function from javascript in asp.net?
本文介绍了如何从asp.net中的javascript调用Codebehind函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用javascript从后面的代码中调用函数.我使用了以下代码:
I want to call a function from my code behind using javascript. I used the below code:
function fnCheckSelection() {
some script;
window["My"]["Namespace"]["GetPart"](null);
}
...,其中"GetPart"
是函数名称.但是,这不起作用.请帮助我.
...where "GetPart"
is the function name. However, this is not working. Please help me on this.
推荐答案
在JavaScript中:
in JavaScript:
document.getElementById("btnSample").click();
服务器端控制:
<asp:Button runat="server" ID="btnSample" ClientIDMode="Static" Text="" style="display:none;" OnClick="btnSample_Click" />
C#
protected void btnSample_Click(object sender, EventArgs e)
{
}
这是一种简单的方法...
It is easy way though...
这篇关于如何从asp.net中的javascript调用Codebehind函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文