Copy text to clipboard


I understand that copying to the client clipboard has to be done in 2 operations… Clipboard.SetClientText writes to temporary storage on the client.  And then javascript can execute Wisej.Core.Copy(); to retrieve that text and put it on the clipboard.

But its not working for me.  Here is my code.  What am I doing wrong?

Thanks in advance,



Private Sub lblURL_Click(sender As Object, e As EventArgs) Handles lblURL.Click
End Sub

  • You must to post comments
Best Answer

Thank you Luca, I see the distinction now.

I implemented it using a button (called “Copy”) which sets the text on the client side, and displays a confirming button (called “Copy URL?”).  The confirming button uses the javascript extender control and executes the javascript to do the copy().

Works perfectly, thanks.



  • You must to post comments

Found a better solution. You can do both steps with 1 click and 1 button. Attach the “execute” event using the Javascript extender and use this js code:

    var box = new wisej.web.AlertBox().set({
        message:"Clipboard data copied!"
}, 500);


Adjust as needed. Then attach the click event handler on the server (same button) and use SetClientText(). Turns out that the click will execute both, the client code and the server code and setTimeout() marks the function as “safe” when started from a user event. You  may have to adjust the 500ms timeout or check if Wisej.Core.clipoardText is > “” or reschedule.


  • You must to post comments

You can’t call “copy()” from the server, that’s why we need two steps. All browsers stop ajax calls from setting the clipboard. copy() must be called on the client by a client-initiated event, like a user click and a javascript client side only event.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.