[英]how to call a server-side ASP.NET event from the client-side
I have an asp.net button in the gridview footer, and I wanna to call the server-side ASP.NET button event in the client side (JavaScript). 我在gridview页脚中有一个asp.net按钮,我想在客户端(JavaScript)中调用服务器端ASP.NET按钮事件。
How to do this please code details if possible. 如何执行此操作,请在可能的情况下编码详细信息。
My .aspx: 我的.aspx:
<FooterTemplate>
<asp:ImageButton ID="ibtn_add" ImageUrl="~/Images/accord_plus.png"
runat="server" OnClick="ibtn_add_Click" />
</FooterTemplate>
I wanna to know how to call the ibtn_add_Click
in the client side. 我想知道如何在客户端调用
ibtn_add_Click
。
in the following code: 在以下代码中:
var isShift = false;
document.onkeyup = function(e)
{ if (e.which == 16) isShift = false; }
document.onkeydown = function(e) {
if (e.which == 16) isShift = true;
if (e.which == 13 && isShift == true) {
//Here I wanna to call ibtn_add_Click
return false;
}
}
Note : 注意 :
The gridview in an update panel, and I execute the JavaScript through: 在更新面板中的gridview中,我通过以下方式执行JavaScript:
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/Shortcut.js" />
</Scripts>
</asp:ScriptManager>
I think you want something like this ... 我想你想要这样的东西...
if (e.which == 13 && isShift == true)
{
__doPostBack('ibtn_add','OnClick');
return false;
}
You might use ajax and make a call to webservice or web method or you can use or you can use 您可能使用ajax并调用了Web服务或Web方法,或者可以使用或者可以使用
__doPostBack(‘btntest','OnClick')
or 要么
$('btntest').trigger('click');
chck this link : http://codethatworkedforme.blogspot.com/2011/08/some-tricks-for-asynchronous-postback.html 单击此链接: http ://codethatworkedforme.blogspot.com/2011/08/some-tricks-for-asynchronous-postback.html
<asp:ImageButton ID="ibtn_add" ImageUrl="~/Images/accord_plus.png" runat="server" OnClick="ibtn_add_Click" />
这是我遇到的问题,但仅用于OnClientClick
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.