简体   繁体   English

OnClientClick OnClick

[英]OnClientClick OnClick

In my asp page, I take a screenshot of the client's desktop with an applet and ask them to send it to the server with a single click of a LinkButton . 在我的asp页面中,我使用applet截取了客户端桌面的屏幕快照,并要求他们单击LinkButton将其发送到服务器。 I use runApplet() function to call my applet to capture the screen and assign the strings value to a hidden value. 我使用runApplet()函数来调用我的applet来捕获屏幕并将字符串值分配给隐藏值。 (picture is stored as base64 string) Until here, everything works perfect! (图片存储为base64字符串)直到这里,一切都完美! However, SendLinkButton_Click doesnt seem to be executing! 但是,SendLinkBut​​ton_Click似乎没有执行!

This is my link button. 这是我的链接按钮。

<asp:LinkButton ID="SendLinkButton" 
          OnClientClick="runApplet(); return false;"
          OnClick="SendLinkButton_Click" 
          Visible="false" 
          CssClass="portal-arrow portal-button"
          runat="server">Send</asp:LinkButton>

This is my Javascript function 这是我的Javascript函数

   function runApplet() {

      var msg = document.capture.capture();
      var hiddenControl = '<%= inpHide.ClientID %>';
      document.getElementById(hiddenControl).value = msg;
   }

and this is what's inside of SendLinkButton_Click 这就是SendLinkBut​​ton_Click的内容

protected void SendLinkButton_Click(object sender, EventArgs e)
{
    Server.Transfer("Preview.aspx", true);
}

when I put the javascript function to a LinkButton's OnClientClick, and execute this "SendLinkButton_Click" with another LinkButton. 当我将JavaScript函数放到LinkBut​​ton的OnClientClick上,并使用另一个LinkBut​​ton执行此“ SendLinkBut​​ton_Click”时。 It works perfect! 它工作完美! But I want them to work with just one click! 但我希望他们只需单击一下即可工作!

Please help! 请帮忙!

Your client click is returning false so no postback will be made to the server after this point. 您的客户点击返回的是false,因此此后将不向服务器发回邮件。

Try changing: 尝试更改:

OnClientClick="runApplet(); return false;"

To

OnClientClick="runApplet();"

Remove return false from the OnClientClick attribute. 从OnClientClick属性中删除return false If you return false from it, the postback will not execute. 如果从中返回false,则不会执行回发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM