简体   繁体   中英

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 . I use runApplet() function to call my applet to capture the screen and assign the strings value to a hidden value. (picture is stored as base64 string) Until here, everything works perfect! However, SendLinkButton_Click doesnt seem to be executing!

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

   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

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. 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.

Try changing:

OnClientClick="runApplet(); return false;"

To

OnClientClick="runApplet();"

Remove return false from the OnClientClick attribute. If you return false from it, the postback will not execute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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