[英]Trigger both 'onClick' and 'onClientClick' event on an ASP button from Javascript
I'm working on an existing code and came across a ASP button which has a onClick and onClientClick event on it. 我正在处理现有代码,并且遇到了上面具有onClick和onClientClick事件的ASP按钮。
I'm trying to generate a click event from an external Javascript file so that both the events are triggered. 我正在尝试从外部Javascript文件生成click事件,以便触发两个事件。
I'm using the below line to achive it- 我正在使用下面的代码来实现它-
document.getElementById("ID_ReleaseUserAuthPending_okBtn").click();
But the OnClientClick event is being triggered as expected, but the onClick event isn't. 但是OnClientClick事件已按预期方式触发,但onClick事件并未触发。 ie, The Javascript method is being processed, but the onClick() in the C# codebehind isn't.
即,正在处理Javascript方法,但未处理C#代码中的onClick()。
Please help me out if there is any way where I can call the onClick event too. 如果可以通过任何方式调用onClick事件,请帮助我。
Thanks in advance. 提前致谢。
At the end of javascript method put 在javascript方法末尾放
return true;
statement. 声明。
It should work. 它应该工作。
From the client click function, from js, call __dopostback. 从客户端单击功能,从js,调用__dopostback。 That is underscore underscore do post back.
那是下划线下划线确实回发。 You can google it for sample code.
您可以将其搜索为示例代码。 https://www.codeproject.com/articles/667531/dopostback-function
https://www.codeproject.com/articles/667531/dopostback-function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.